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

fix for issue where s3 lifecycle rule prefix key value is not set corr… #1350

Merged
merged 1 commit into from
Aug 7, 2017
Merged

Conversation

Preston4tw
Copy link
Contributor

@Preston4tw Preston4tw commented Aug 4, 2017

…ectly if prefix is not under the filter key

On Terraform v0.10.0, it looks there is an issue where the prefix value on a s3 bucket lifecycle policy is not set when it is not under a filter key in the document returned from the AWS API.

Here's the DEBUG log output showing the prefix in the AWS API document:

2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws: 2017/08/04 14:52:45 [DEBUG] S3 Bucket: my-bucket, lifecycle: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:   Rules: [{
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       AbortIncompleteMultipartUpload: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:         DaysAfterInitiation: 7
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       },
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Expiration: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       },
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       ID: "<redacted-1>",
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       NoncurrentVersionExpiration: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       },
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Prefix: "some_prefix_1/",
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Status: "Enabled"
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:     },{
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       AbortIncompleteMultipartUpload: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:         DaysAfterInitiation: 7
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       },
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Expiration: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:         Days: 368
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       },
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       ID: "<redacted-2>",
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       NoncurrentVersionExpiration: {
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:         NoncurrentDays: 10
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       },
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Prefix: "some_prefix_2/",
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Status: "Enabled",
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:       Transitions: [{
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:           Days: 15,
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:           StorageClass: "GLACIER"
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:         }]
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws:     }]
2017/08/04 14:52:45 [DEBUG] plugin: terraform-provider-aws: }

@Preston4tw
Copy link
Contributor Author

Actually, looking at GH-1316, I don't think there was a bug introduced there. Perhaps the AWS API document changed that caused this behavior. At any rate, this PR fixes the issue I'm having.

@Preston4tw Preston4tw changed the title fix for GH-1316 where s3 lifecycle rule prefix key value is not set corr… fix for issue where s3 lifecycle rule prefix key value is not set corr… Aug 4, 2017
@opalmer
Copy link

opalmer commented Aug 4, 2017

@Preston4tw this seems pretty similar to #1349?

Looking at https://www.terraform.io/docs/providers/aws/r/s3_bucket.html it seems like lifecycle_rule.prefix is a required attribute but if I remove the attribute from my own template terraform plan still works. Not suggesting any changes here, just seemed like lifecycleRule.Prefix is supposed to never be nil but actually can be heh.

@Preston4tw
Copy link
Contributor Author

I initially thought the issue was related but it doesn't appear to be.

My issue is the TF prefix attribute of lifecycles blocks are not being set for the s3 resource on refresh and import. Plan incorrectly then wants to update the s3 lifecycle prefixes when they're correct.

The debug log also shows the prefix attributes present in the AWS API JSON response, so it looks like it's just an issue with the read/parse code. It looks like the code expects the prefix key to be under a filter key, which in my case it is not.

@grubernaut grubernaut added the bug Addresses a defect in current functionality. label Aug 7, 2017
Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@grubernaut grubernaut merged commit 119dd06 into hashicorp:master Aug 7, 2017
@ghost
Copy link

ghost commented Apr 11, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants