- Show how a browser requests S3 content directly (no CloudFront).
- Upload a simple object to an S3 bucket, make it temporarily public, and test direct access.
- Re-lock the bucket, create a CloudFront distribution configured to access the private S3 origin via OAC, and test access through CloudFront.
- Clean up created resources.
- Without CloudFront: the browser requests objects directly from the S3 Regional endpoint.
- With CloudFront: the browser hits a CloudFront edge location; CloudFront fetches the origin (S3) and can cache content closer to users.
- S3 console: https://console.aws.amazon.com/s3/
- CloudFront console: https://console.aws.amazon.com/cloudfront/
- AWS doc: Restricting Access to S3 for CloudFront — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html

- Bucket name used in this demo:
eden-kk-cloud-bkt
index.html (for example, an H1 with “Hello world”) to the bucket. This will be the object we test.

- In the S3 bucket Permissions, edit the Block public access settings and disable the relevant block(s) to permit public reads.
- Add a bucket policy that grants
s3:GetObjectto all principals for objects in the bucket (only for this controlled demo).
Enabling public access or adding a broad bucket policy can expose your objects. Only use this approach in a controlled demo or test environment and remove the policy immediately after testing.
index.html content (e.g., “Hello world!”) served directly from S3:

Use a unique bucket name in your AWS account. Enabling public access or applying broad bucket policies can expose your objects—only do this in a controlled demo or test environment.
- Re-enable “Block all public access”.
- Remove the read-all bucket policy.
- Confirm the Permissions tab shows public access is blocked.


- Use the default settings.
- Create a single website configuration (one distribution serving one site).
- Optionally give a friendly name like
CF-eden-KK.

- Origin type: Amazon S3.
- Use the “Browse S3” option and select your
eden-kk-cloud-bktbucket. - Enable the AWS-configured Origin Access Control (OAC). OAC lets CloudFront sign requests to S3 so the bucket can remain private while CloudFront is authorized to fetch objects on behalf of clients.
https://<your-cloudfront-domain>/index.html
Because the S3 bucket is private and CloudFront uses OAC credentials, CloudFront becomes the only authorized way to fetch the object from S3 on behalf of clients. Direct S3 object URL access will return Access Denied until permissions are changed.
S3 Permissions confirm the bucket is private:

- The client requests the CloudFront domain.
- CloudFront checks cache at the edge; if missing or expired, CloudFront uses OAC-signed requests to fetch the object from the private S3 origin.
- CloudFront caches the object at edge locations, improving latency for subsequent requests.
- CloudFront also enables features such as custom TLS certificates, WAF integration, finer cache-control, and performance optimizations.
- Disable the CloudFront distribution, then delete it (distributions must be disabled before deletion; propagation can take several minutes).
- Delete all objects in the S3 bucket and then delete the bucket.



Summary
- Direct S3 hosting is simple but typically requires public object access or permissive policies.
- CloudFront acts as a secure front door to a private S3 bucket when configured with OAC: CloudFront fetches objects on behalf of clients and caches them at edge locations, improving performance and security.
- For production static websites or assets, prefer CloudFront + private S3 with OAC for better security, performance, and control.
- AWS S3 documentation: https://docs.aws.amazon.com/s3/index.html
- AWS CloudFront documentation: https://docs.aws.amazon.com/cloudfront/index.html
- Restricting access to S3 for CloudFront (detailed guide): https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html