Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing aws_s3_bucket_lifecycle_configuration resource from HCL doesn't destroy it #25409

Closed
Justin-W opened this issue Jun 16, 2022 · 2 comments
Labels
service/s3 Issues and PRs that pertain to the s3 service.

Comments

@Justin-W
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v1.1.9
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v4.15.1

Affected Resource(s)

  • aws_s3_bucket_lifecycle_configuration
  • aws_s3_bucket

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

NOTE: The following resource declaration was one of the removed resources. The others were similar, but for different buckets. The HCL below was successfully applied by terraform apply, prior to the removal of the HCL (which was followed by the unsuccessful/no-op terraform apply).

resource "aws_s3_bucket_lifecycle_configuration" "my-bucket-lifecycle" {
  provider = aws.myprov
  bucket = "my-bucket"

  rule {
    id     = "base-lifecycle"
    status = "Disabled"

    abort_incomplete_multipart_upload {
      days_after_initiation = "7"
    }

    transition {
      days          = "90"
      storage_class = "GLACIER"
    }
    noncurrent_version_transition {
      noncurrent_days = "90"
      storage_class   = "GLACIER"
    }

    expiration {
      days = "1825"
    }
    noncurrent_version_expiration {
      noncurrent_days = "1825"
    }
  }
}

Debug Output

Panic Output

Expected Behavior

Removing the HCL for an already-provisioned aws_s3_bucket_lifecycle_configuration resource should cause terraform apply to destroy/delete the actual resources/rules within the AWS env.

Actual Behavior

After removing the HCL for an already-provisioned aws_s3_bucket_lifecycle_configuration resource, the subsequent terraform apply did not update or remove/destroy any S3-related resources. The corresponding AWS S3 buckets now appear to have "orphaned" lifecycle rules, which are visible within the AWS console, but which no longer have any corresponding TF HCL resource declarations.

Steps to Reproduce

  1. Migrated existing AWS v3.x-style HCL to use the new v4.x-style aws_s3_bucket_lifecycle_configuration resources.
  2. terraform apply
  3. Removed the new aws_s3_bucket_lifecycle_configuration resources from the HCL.
  4. terraform apply (Note that the TF plan shows nothing to destroy/modify, even though HCL resource declarations were removed.)

Important Factoids

I couldn't find any documentation (at the locations below) which would indicate that the unexpected behavior (as described above) is intentional. Therefore, I assume that this is

References

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/s3 Issues and PRs that pertain to the s3 service. labels Jun 16, 2022
@Justin-W
Copy link
Author

Found the problem. User error. Not a TF problem. Please disregard this bug. Thanks.

@github-actions github-actions bot removed the needs-triage Waiting for first response or review from a maintainer. label Jun 16, 2022
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
Development

No branches or pull requests

1 participant