Skip to content

Fix/shared bucket policy#5

Closed
agustincelentano wants to merge 3 commits intomainfrom
fix/shared-bucket-policy
Closed

Fix/shared bucket policy#5
agustincelentano wants to merge 3 commits intomainfrom
fix/shared-bucket-policy

Conversation

@agustincelentano
Copy link
Copy Markdown
Contributor

No description provided.

…rent deployments

Move bucket policy management from Terraform to a dedicated script that
reads the existing policy and adds/removes only its own statement (keyed
by distribution ID). This prevents one deployment from overwriting or
deleting statements belonging to other CloudFront distributions sharing
the same S3 bucket.

On delete, the workflow now removes the bucket policy statement BEFORE
tofu destroy runs, while the distribution ID is still available in state.
Replace distribution-specific SourceArn condition with account-level
SourceAccount condition. This makes the policy idempotent across multiple
CloudFront distributions sharing the same S3 bucket, preventing one
deployment from overwriting or deleting another's access.
Use -exclude=aws_s3_bucket_policy.static on destroy so the shared
bucket policy is preserved when a deployment is deleted. Other
distributions sharing the same bucket keep working.
jcastiarena added a commit that referenced this pull request Apr 17, 2026
Adds 3 IAM statements that were missing from the updated policy:

- route53:GetChange on change/* — AWS provider polls this for DNS
  propagation; without it, deploy fails with AccessDenied AFTER creating
  the record (discovered in POC deploy #5)
- route53:ListHostedZones + ListHostedZonesByName on * — these two
  actions don't support resource-level permissions; Resource must be *
  (the only unavoidable wildcard in the policy)
- acm:GetCertificate on arn:aws:acm:us-east-1:YOUR_ACCOUNT_ID:certificate/*
  — provider calls both GetCertificate and DescribeCertificate; scoped
  to us-east-1 (CloudFront requirement) + account

Also adds a placeholder replacement table to the README IAM section:
YOUR_STATE_BUCKET, YOUR_ASSETS_BUCKET, YOUR_HOSTED_ZONE_ID, YOUR_ACCOUNT_ID
with sources and examples.

Co-Authored-By: Claude Opus 4.6 (1M context) <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