SKY-D414 · Deployment and infrastructure
Terraform plan deletes an S3 bucket while retaining its DNS record
The AWS provider plans to delete an S3 bucket while a Route 53 CNAME continues to point to its endpoint. The record's fully qualified name matches the bucket name.
- Languages
- Terraform plan JSON
- Turned on by
- Export the saved plan locally with
terraform show -json saved.tfplan > plan.json. The export can contain sensitive values. Pass the local file toskylos rules terraform-plan plan.json --format json. The result identifies the matching entries by JSON pointer. - Quality gate
- not checked (full and diff scans)
- Needs
- Run skylos rules terraform-plan plan.json before applying a saved plan.
- Finding type
- review
Why it matters
DNS can continue sending clients to S3 after the bucket is released. Retire or retarget the record before the bucket name becomes available.
What Skylos flags
{ "format_version": "1.2", "complete": true, "errored": false, "resource_changes": [ { "address": "aws_s3_bucket.archive", "mode": "managed", "type": "aws_s3_bucket", "provider_name": "registry.terraform.io/hashicorp/aws", "change": { "actions": ["delete"], "before": {"bucket": "archive.example.test"}, "after": null } }, { "address": "aws_route53_record.archive", "mode": "managed", "type": "aws_route53_record", "provider_name": "registry.terraform.io/hashicorp/aws", "change": { "actions": ["no-op"], "before": { "type": "CNAME", "fqdn": "archive.example.test", "records": ["archive.example.test.s3.amazonaws.com"] }, "after": { "type": "CNAME", "fqdn": "archive.example.test", "records": ["archive.example.test.s3.amazonaws.com"] } } } ]}What Skylos leaves alone
{ "format_version": "1.2", "complete": true, "errored": false, "resource_changes": [ { "address": "aws_route53_record.archive", "mode": "managed", "type": "aws_route53_record", "provider_name": "registry.terraform.io/hashicorp/aws", "change": { "actions": ["delete"], "before": { "type": "CNAME", "fqdn": "archive.example.test", "records": ["archive.example.test.s3.amazonaws.com"] }, "after": null } } ]}Why Skylos leaves it alone
The plan retires the CNAME while the bucket is still available.
How Skylos decides
- Reads an explicitly supplied JSON plan with format version 1.x, a complete plan marker and the resource changes. Matches the bucket's recorded identity to the DNS name and S3 target. A planned bucket with the same name can account for a replacement. When Terraform deletes a shared-name bucket before recreating it, an unchanged CNAME also gets a review for the interval between those actions.
- A pending deletion of a previously replaced bucket is checked by its own prior bucket name. S3 account-regional names remain reserved to the account after deletion.
- Returns 0 when the supported check completes without a match, 1 for a finding and 2 when the input or a necessary value leaves the check incomplete. The result describes the planned configuration. Actual DNS visibility, bucket ownership after apply and resources managed elsewhere require separate evidence.
How to fix it
Retire or retarget the DNS record first. Allow cached DNS answers to expire before releasing the bucket. Generate a fresh plan for the bucket deletion and review it again.
When it can be wrong
- A separate deployment may already have changed the record or preserved ownership of the name. Verify the order of those changes.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
The standalone command takes one plan per invocation. Callers decide how to handle its review exit status.