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

Changes to S3 Bucket Lifecycle policies don't converge (>v2.64.0) #14280

Closed
dicconb opened this issue Jul 21, 2020 · 4 comments
Closed

Changes to S3 Bucket Lifecycle policies don't converge (>v2.64.0) #14280

dicconb opened this issue Jul 21, 2020 · 4 comments
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@dicconb
Copy link

dicconb commented Jul 21, 2020

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 -v
Terraform v0.12.28
+ provider.aws v2.70.0

Affected Resource(s)

  • aws_s3_bucket

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

resource aws_s3_bucket "test" {
  lifecycle_rule {
    id                                     = "Test"
    enabled                                = true
    prefix                                 = ""
    abort_incomplete_multipart_upload_days = 7
  }
}

Debug Output

https://gist.github.com/dicconb/53fd9638f4c68923a2cb37b185187bd6

Expected Behavior

  • First apply should create the lifecycle policy
  • Second apply (and subsequent applies) should show no changes

Actual Behavior

  • First apply creates the lifecycle policy, with an extraneous expiration block that isn't visible in the plan
    Plan:
# aws_s3_bucket.test will be created
  + resource "aws_s3_bucket" "test" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = (known after apply)
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + lifecycle_rule {
          + abort_incomplete_multipart_upload_days = 7
          + enabled                                = true
          + id                                     = "Test"
        }

      + versioning {
          + enabled    = (known after apply)
          + mfa_delete = (known after apply)
        }
    }

Lifecycle rule:

aws s3api get-bucket-lifecycle --bucket terraform-20200721180953452800000001
{
    "Rules": [
        {
            "Expiration": {
                "ExpiredObjectDeleteMarker": false
            },
            "ID": "Test",
            "Status": "Enabled",
            "AbortIncompleteMultipartUpload": {
                "DaysAfterInitiation": 7
            }
        }
    ]
}
  • Second apply attempts to remove the extraneous expiration block, and appears to succeed
      ~ lifecycle_rule {
            abort_incomplete_multipart_upload_days = 7
            enabled                                = true
            id                                     = "Test"
            tags                                   = {}

          - expiration {
              - days                         = 0 -> null
              - expired_object_delete_marker = false -> null
            }
        }
[...]
aws_s3_bucket.test: Modifying... [id=terraform-20200721165752214400000001]
aws_s3_bucket.test: Still modifying... [id=terraform-20200721165752214400000001, 10s elapsed]
aws_s3_bucket.test: Modifications complete after 19s [id=terraform-20200721165752214400000001]

However the lifecycle rule is still present

  • Third apply is identical to second apply

Steps to Reproduce

  1. terraform apply
  2. terraform apply
  3. terraform apply

Important Factoids

Workaround:

The issue can be worked around by pinning to provider version v2.64.0 or lower for the terraform apply which updates the lifecycle policy, or a subsequent terraform apply. The latest provider version can be used for any terraform runs that don't attempt to update S3 Lifecycle rules.

References

@ghost ghost added the service/s3 Issues and PRs that pertain to the s3 service. label Jul 21, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 21, 2020
@dicconb
Copy link
Author

dicconb commented Jul 21, 2020

Acceptance test to catch this issue: #14283

@dicconb
Copy link
Author

dicconb commented Jul 28, 2020

Proposed fix: #14284

@breathingdust breathingdust added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 8, 2021
@anGie44
Copy link
Contributor

anGie44 commented Mar 11, 2022

Hi @dicconb , thank you for raising this issue and apologies it did not get linked sooner to the fix in v3.10.0 of the AWS provider. I'm going to close this issue as the fix (#15263) was released (and will follow-up on #14284).

@anGie44 anGie44 closed this as completed Mar 11, 2022
@anGie44 anGie44 added this to the v3.10.0 milestone Mar 11, 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 May 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants