Skip to content

feat(requirements/aws): output CloudFront OAC bucket-policy statement#18

Open
sebastiancorrea81 wants to merge 2 commits into
mainfrom
feat/requirements-aws-cloudfront-oac-policy-output
Open

feat(requirements/aws): output CloudFront OAC bucket-policy statement#18
sebastiancorrea81 wants to merge 2 commits into
mainfrom
feat/requirements-aws-cloudfront-oac-policy-output

Conversation

@sebastiancorrea81

Copy link
Copy Markdown
Contributor

Summary

  • The static-files scope's cloudfront/setup validates but never writes the assets-bucket policy that grants CloudFront OAC (cloudfront.amazonaws.com) read access — it's a manual, disconnected pre-requisite today, and it has gone missing after CloudFront distribution replacements.
  • requirements/aws now optionally emits that statement as a ready-to-merge IAM policy document (cloudfront_oac_bucket_policy_json), gated by the new assets_bucket_arn input.
  • Deliberately does not create an aws_s3_bucket_policy resource here: the assets bucket's policy is already owned by another module, and a bucket can only be managed by one such resource. Consumers merge this output into their existing policy document via source_policy_documents.
  • Data source lives in data.tf, following the module's existing convention.

Test plan

  • tofu fmt -check -diff clean
  • tofu validate passes
  • Consumer stack merges cloudfront_oac_bucket_policy_json into its existing aws_s3_bucket_policy and confirms cloudfront/setup's bucket-policy check passes on the next deployment

🤖 Generated with Claude Code

sebas_correa and others added 2 commits July 20, 2026 16:39
The static-files scope validates but never writes the assets-bucket
policy that grants CloudFront OAC read access, so it repeatedly went
missing after distribution replacements when maintained by hand.

Expose the AllowCloudFrontOACRead statement as a JSON output
(assets_bucket_arn -> cloudfront_oac_bucket_policy_json) instead of
creating an aws_s3_bucket_policy resource here, since the assets
bucket's policy is already owned by another module and a bucket can
only have one such resource. Consumers merge the output into their
existing policy document via source_policy_documents.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… data.tf

Follow the module's existing convention of grouping data sources in
data.tf instead of a dedicated file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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