Skip to content

feat: enforce CloudFront OAC on S3 bucket#5

Open
xczimi wants to merge 1 commit intomainfrom
feature/s3-oac
Open

feat: enforce CloudFront OAC on S3 bucket#5
xczimi wants to merge 1 commit intomainfrom
feature/s3-oac

Conversation

@xczimi
Copy link
Owner

@xczimi xczimi commented Feb 8, 2026

Summary

  • Replace Principal: "*" S3 bucket policy with CloudFront service principal scoped by AWS:SourceArn, so only the CloudFront distribution can access S3 objects
  • Enable all S3 public access block settings (block_public_acls, block_public_policy, ignore_public_acls, restrict_public_buckets)
  • Remove unused aws_s3_bucket_website_configuration — CloudFront already uses the REST endpoint with its function handling index.html rewrites

Test plan

  • Run AWS_PROFILE=xczimi tofu -chdir=infrastructure plan and confirm 2 updates + 1 destroy
  • Run tofu apply and verify success
  • Confirm direct S3 URL returns 403 Forbidden
  • Confirm https://xczimi.com loads normally through CloudFront

Replace Principal: "*" bucket policy with CloudFront service principal
scoped to the distribution ARN. Enable S3 public access block and remove
the unused S3 website configuration since CloudFront uses the REST
endpoint with its function handling index.html rewrites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant