Create S3

Create S3 bucket

  1. Open the S3 console at https://console.aws.amazon.com/s3/
    • Select General purpose buckets
    • Select Create bucket Create S3
  2. In General configuration:
    • AWS Region: the same Region as your EC2 instance
    • Bucket type: General purpose
    • Bucket namespace: Account Regional namespace (recommended)
    • Bucket name prefix: cloudfront-lab Create S3

      AWS appends a suffix to the prefix, so the bucket name becomes cloudfront-lab-<account-id>-<region>-an.

  3. Keep the defaults:
    • Block Public Access settings for this bucket: Block all public access checked
    • Bucket Versioning: Disable Create S3

      The bucket stays private. In section 3, you grant CloudFront access to it.

  4. Keep the remaining defaults and select Create bucket:
    • Default encryption: Server-side encryption with Amazon S3 managed keys (SSE-S3)
    • Bucket Key: Enable Create S3

Upload index.html

  1. On your computer, create a file named index.html with the following content:
<!DOCTYPE html>
<html lang="en">
  <body>
    <table border="1" width="100%">
      <thead>
        <tr>
          <td><h1>CloudFront Lab</h1></td>
        </tr>
      </thead>
      <tfoot>
        <tr>
          <td>Immersion Days - Edge Services - Module 1</td>
        </tr>
      </tfoot>
      <tbody>
        <tr>
          <td>Response sent by API</td>
        </tr>
      </tbody>
      <tbody>
        <tr>
          <td>
            <iframe src="/api" style="width: 100%; height: 100%"></iframe>
          </td>
        </tr>
      </tbody>
    </table>
  </body>
</html>
  1. In the S3 console, open the bucket. On the Objects tab, select Upload. Create S3
  2. Select Add files, choose index.html, then select Upload. Create S3
  3. Check the Upload: status page. Create S3
  4. Select index.html and copy the Object URL. Create S3
  5. Open the Object URL in a new tab. S3 returns AccessDenied because the bucket blocks public access. This is expected: later you serve the file through CloudFront. Create S3