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 S3 bucket lifecycle rule filters with a single tag and no prefix #7162

Merged
merged 5 commits into from
Jul 10, 2019

Conversation

pdecat
Copy link
Contributor

@pdecat pdecat commented Jan 16, 2019

Fixes #7156

Changes proposed in this pull request:

  • support S3 bucket lifecycle rule filters with a single tag and no prefix

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSS3Bucket_LifecycleBasic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]

=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (141.42s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       141.443s

TODO:

  • verify fix in real situation
  • generate lifecycle rules with a single tag and no prefix the same way the web console does

Notes:

  • Rather than trying to add an acceptance test that creates a lifecycle rule with a single tag and no prefix the same way the web console would have done, I've settled to adapt the provider's update implementation to match the web console behavior.

  • Adding unit tests would probably be a good thing but this would require extracting lifecycle rules expanding/flattening code into functions and make the diff way less readable.

@ghost ghost added size/S Managed by automation to categorize the size of a PR. service/s3 Issues and PRs that pertain to the s3 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 16, 2019
@pdecat pdecat changed the title Fix S3 bucket lifecycle rule filters with a single tag and no prefix WIP: Fix S3 bucket lifecycle rule filters with a single tag and no prefix Jan 16, 2019
@pdecat
Copy link
Contributor Author

pdecat commented Jan 16, 2019

This change is not working in real situation using the terraform configuration from #7156 :(

Read during plan phase:

2019-01-16T19:47:10.760+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-f42c7c01: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Filter><Tag><Key>testtag1</Key><Value>testtag1</Value></Tag></Filter><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>

Written during apply phase:

2019-01-16T19:47:20.045+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-f42c7c01: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><Filter><Prefix></Prefix></Filter><ID>test</ID><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>

Re-read after apply phase:

2019-01-16T19:47:26.092+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-f42c7c01: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Filter><Prefix></Prefix></Filter><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>

Filter with single tag is still removed...

@pdecat
Copy link
Contributor Author

pdecat commented Jan 16, 2019

Oh, this fix does work, I did not properly build the provider on my test machine in my first test :)

Read during plan phase:

2019-01-16T23:23:00.750+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-8eef2af9: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Filter><Tag><Key>testtagname</Key><Value>testtagvalue</Value></Tag></Filter><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>

Written during apply phase:

2019-01-16T23:23:10.073+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-8eef2af9: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><Filter><And><Prefix></Prefix><Tag><Key>testtagname</Key><Value>testtagvalue</Value></Tag></And></Filter><ID>test</ID><Status>Enabled</Status><Transition><StorageClass>STANDARD_IA</StorageClass><Days>30</Days></Transition></Rule></LifecycleConfiguration>

Re-read after apply phase:

2019-01-16T23:23:16.658+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-8eef2af9: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Filter><And><Prefix></Prefix><Tag><Key>testtagname</Key><Value>testtagvalue</Value></Tag></And></Filter><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>

Note that this adds an empty prefix but is still interpreted the same in the web console.

@pdecat pdecat changed the title WIP: Fix S3 bucket lifecycle rule filters with a single tag and no prefix Fix S3 bucket lifecycle rule filters with a single tag and no prefix Jan 16, 2019
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 56bb1d6 to ee4ae35 Compare January 16, 2019 22:34
@pdecat
Copy link
Contributor Author

pdecat commented Jan 16, 2019

Re-tested with more debug logs.

Read during plan phase:

2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Filter><Tag><Key>testtagname</Key><Value>testtagvalue</Value></Tag></Filter><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: 2019/01/16 23:37:34 [DEBUG] S3 bucket: s3.tf-test-pdecat-feeea921a342cce4687c932ed9e2, read lifecycle rule: {
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   Filter: {
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:     Tag: {
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       Key: "testtagname",
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       Value: "testtagvalue"
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:     }
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   },
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   ID: "test",
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   Status: "Enabled",
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   Transitions: [{
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       Days: 30,
2019-01-16T23:37:34.123+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       StorageClass: "STANDARD_IA"
2019-01-16T23:37:34.124+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:     }]
2019-01-16T23:37:34.124+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: }

Written during apply phase:

2019-01-16T23:37:43.554+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><Filter><And><Prefix></Prefix><Tag><Key>testtagname</Key><Value>testtagvalue</Value></Tag></And></Filter><ID>test</ID><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>

Re-read after apply phase:

2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Filter><And><Prefix></Prefix><Tag><Key>testtagname</Key><Value>testtagvalue</Value></Tag></And></Filter><Status>Enabled</Status><Transition><Days>30</Days><StorageClass>STANDARD_IA</StorageClass></Transition></Rule></LifecycleConfiguration>
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: 2019/01/16 23:37:49 [DEBUG] S3 bucket: s3.tf-test-pdecat-feeea921a342cce4687c932ed9e2, read lifecycle rule: {
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   Filter: {
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:     And: {
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       Prefix: "",
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       Tags: [{
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:           Key: "testtagname",
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:           Value: "testtagvalue"
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:         }]
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:     }
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   },
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   ID: "test",
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   Status: "Enabled",
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:   Transitions: [{
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       Days: 30,
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:       StorageClass: "STANDARD_IA"
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351:     }]
2019-01-16T23:37:49.576+0100 [DEBUG] plugin.terraform-provider-aws_v1.57.0-ee4ae351: }

@@ -755,7 +755,7 @@ func TestAccAWSS3Bucket_Logging(t *testing.T) {
})
}

func TestAccAWSS3Bucket_Lifecycle(t *testing.T) {
func TestAccAWSS3Bucket_LifecycleBasic(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewers: this allows to target this acceptance test without also matching the TestAccAWSS3Bucket_LifecycleExpireMarkerOnly test.

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from ee4ae35 to f237933 Compare January 31, 2019 11:57
@pdecat
Copy link
Contributor Author

pdecat commented Jan 31, 2019

Also worth noting, this case is somewhat documented in the vendored AWS SDK:

	// The Filter is used to identify objects that a Lifecycle Rule applies to.
	// A Filter must have exactly one of Prefix, Tag, or And specified.
	Filter *LifecycleRuleFilter `type:"structure"`

cf. https:/terraform-providers/terraform-provider-aws/blob/v1.57.0/vendor/github.com/aws/aws-sdk-go/service/s3/api.go#L15319

@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Jan 31, 2019
@pdecat
Copy link
Contributor Author

pdecat commented Jan 31, 2019

Acceptance test results:

# make testacc TESTARGS='-run=TestAccAWSS3Bucket_Lifecycle.*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSS3Bucket_Lifecycle.* -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== RUN   TestAccAWSS3Bucket_LifecycleExpireMarkerOnly
=== PAUSE TestAccAWSS3Bucket_LifecycleExpireMarkerOnly
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleExpireMarkerOnly
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (95.62s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (140.29s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       140.319s

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 8c426be to c56cc2a Compare February 5, 2019 16:47
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from c56cc2a to b84c62e Compare February 13, 2019 07:54
@pdecat
Copy link
Contributor Author

pdecat commented Feb 13, 2019

Hi @bflad, would you mind having a look at this one?

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from b84c62e to 668bd49 Compare February 18, 2019 10:54
@ghost ghost added size/S Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Feb 18, 2019
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 668bd49 to 3cdf19a Compare March 6, 2019 08:56
@pdecat
Copy link
Contributor Author

pdecat commented Mar 6, 2019

Rebased on master.

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 3cdf19a to 786556f Compare March 12, 2019 11:54
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 786556f to ccc4aad Compare April 1, 2019 09:49
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from ccc4aad to b7f6ce0 Compare April 10, 2019 11:46
@pdecat
Copy link
Contributor Author

pdecat commented Apr 10, 2019

Rebased on master.

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from b7f6ce0 to 894704f Compare April 19, 2019 12:24
@pdecat
Copy link
Contributor Author

pdecat commented Apr 19, 2019

Rebased on master, acceptance tests are no longer passing ;( (not sure what happened there):

# make testacc TEST=./aws TESTARGS='-run=TestAccAWSS3Bucket_LifecycleBasic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- FAIL: TestAccAWSS3Bucket_LifecycleBasic (155.63s)
    testing.go:568: Step 2 error: After applying this step and refreshing, the plan was not empty:

        DIFF:

        UPDATE: aws_s3_bucket.bucket
          acceleration_status:                                            "" => ""
          acl:                                                            "public-read" => "public-read"
          arn:                                                            "arn:aws:s3:::tf-test-bucket-2576925322492803950" => "arn:aws:s3:::tf-test-bucket-2576925322492803950"
          bucket:                                                         "tf-test-bucket-2576925322492803950" => "tf-test-bucket-2576925322492803950"
          bucket_domain_name:                                             "tf-test-bucket-2576925322492803950.s3.amazonaws.com" => "tf-test-bucket-2576925322492803950.s3.amazonaws.com"
          bucket_regional_domain_name:                                    "tf-test-bucket-2576925322492803950.s3.us-west-2.amazonaws.com" => "tf-test-bucket-2576925322492803950.s3.us-we
st-2.amazonaws.com"
          cors_rule.#:                                                    "0" => "0"
          force_destroy:                                                  "false" => "false"
          hosted_zone_id:                                                 "Z3BJ6K6RIION7M" => "Z3BJ6K6RIION7M"
          id:                                                             "tf-test-bucket-2576925322492803950" => "tf-test-bucket-2576925322492803950"
          lifecycle_rule.#:                                               "3" => "0"
          lifecycle_rule.0.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.0.enabled:                                       "true" => ""
          lifecycle_rule.0.expiration.#:                                  "0" => ""
          lifecycle_rule.0.id:                                            "id1" => ""
          lifecycle_rule.0.noncurrent_version_expiration.#:               "1" => ""
          lifecycle_rule.0.noncurrent_version_expiration.0.days:          "365" => ""
          lifecycle_rule.0.noncurrent_version_transition.#:               "2" => ""
          lifecycle_rule.0.noncurrent_version_transition.0.days:          "30" => ""
          lifecycle_rule.0.noncurrent_version_transition.0.storage_class: "STANDARD_IA" => ""
          lifecycle_rule.0.noncurrent_version_transition.1.days:          "60" => ""
          lifecycle_rule.0.noncurrent_version_transition.1.storage_class: "GLACIER" => ""
          lifecycle_rule.0.prefix:                                        "path1/" => ""
          lifecycle_rule.0.transition.#:                                  "0" => ""
          lifecycle_rule.1.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.1.enabled:                                       "false" => ""
          lifecycle_rule.1.expiration.#:                                  "0" => ""
          lifecycle_rule.1.id:                                            "id2" => ""
          lifecycle_rule.1.noncurrent_version_expiration.#:               "1" => ""
          lifecycle_rule.1.noncurrent_version_expiration.0.days:          "365" => ""
          lifecycle_rule.1.noncurrent_version_transition.#:               "0" => ""
          lifecycle_rule.1.prefix:                                        "path2/" => ""
          lifecycle_rule.1.transition.#:                                  "0" => ""
          lifecycle_rule.2.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.2.enabled:                                       "true" => ""
          lifecycle_rule.2.expiration.#:                                  "0" => ""
          lifecycle_rule.2.id:                                            "id3" => ""
          lifecycle_rule.2.noncurrent_version_expiration.#:               "0" => ""
          lifecycle_rule.2.noncurrent_version_transition.#:               "1" => ""
          lifecycle_rule.2.noncurrent_version_transition.0.days:          "0" => ""
          lifecycle_rule.2.noncurrent_version_transition.0.storage_class: "GLACIER" => ""
          lifecycle_rule.2.prefix:                                        "path3/" => ""
          lifecycle_rule.2.transition.#:                                  "0" => ""
          logging.#:                                                      "0" => "0"
          object_lock_configuration.#:                                    "0" => "0"
          region:                                                         "us-west-2" => "us-west-2"
          replication_configuration.#:                                    "0" => "0"
          request_payer:                                                  "BucketOwner" => "BucketOwner"
          server_side_encryption_configuration.#:                         "0" => "0"
          versioning.#:                                                   "1" => "1"
          versioning.0.enabled:                                           "false" => "false"
          versioning.0.mfa_delete:                                        "false" => "false"
          website.#:                                                      "0" => "0"



        STATE:

        aws_s3_bucket.bucket:
          ID = tf-test-bucket-2576925322492803950
          provider = provider.aws
          acceleration_status =
          acl = public-read
          arn = arn:aws:s3:::tf-test-bucket-2576925322492803950
          bucket = tf-test-bucket-2576925322492803950
          bucket_domain_name = tf-test-bucket-2576925322492803950.s3.amazonaws.com
          bucket_regional_domain_name = tf-test-bucket-2576925322492803950.s3.us-west-2.amazonaws.com
          force_destroy = false
          hosted_zone_id = Z3BJ6K6RIION7M
          lifecycle_rule.# = 3
          lifecycle_rule.0.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.0.enabled = true
          lifecycle_rule.0.id = id1
          lifecycle_rule.0.noncurrent_version_expiration.# = 1
          lifecycle_rule.0.noncurrent_version_expiration.0.days = 365
          lifecycle_rule.0.noncurrent_version_transition.# = 2
          lifecycle_rule.0.noncurrent_version_transition.0.days = 30
          lifecycle_rule.0.noncurrent_version_transition.0.storage_class = STANDARD_IA
          lifecycle_rule.0.noncurrent_version_transition.1.days = 60
          lifecycle_rule.0.noncurrent_version_transition.1.storage_class = GLACIER
          lifecycle_rule.0.prefix = path1/
          lifecycle_rule.1.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.1.enabled = false
          lifecycle_rule.1.id = id2
          lifecycle_rule.1.noncurrent_version_expiration.# = 1
          lifecycle_rule.1.noncurrent_version_expiration.0.days = 365
          lifecycle_rule.1.prefix = path2/
          lifecycle_rule.2.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.2.enabled = true
          lifecycle_rule.2.id = id3
          lifecycle_rule.2.noncurrent_version_transition.# = 1
          lifecycle_rule.2.noncurrent_version_transition.0.days = 0
          lifecycle_rule.2.noncurrent_version_transition.0.storage_class = GLACIER
          lifecycle_rule.2.prefix = path3/
          region = us-west-2
          request_payer = BucketOwner
          versioning.# = 1
          versioning.0.enabled = false
          versioning.0.mfa_delete = false
FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       155.668s
make: *** [GNUmakefile:20: testacc] Error 1

@pdecat
Copy link
Contributor Author

pdecat commented Apr 19, 2019

Rectification, they do pass:

# make testacc TEST=./aws TESTARGS='-run=TestAccAWSS3Bucket_LifecycleBasic'                                                                                                            
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (162.92s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       162.950s

@pdecat
Copy link
Contributor Author

pdecat commented Apr 20, 2019

I've been running the test in a loop for a while and it is quite flaky and fails from time to time:

# while true ; do make testacc TEST=./aws TESTARGS='-run=TestAccAWSS3Bucket_LifecycleBasic -count=1' ; done
==> Checking that code complies with gofmt requirements...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (159.71s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       159.746s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- FAIL: TestAccAWSS3Bucket_LifecycleBasic (101.05s)
    testing.go:568: Step 1 error: After applying this step and refreshing, the plan was not empty:

        DIFF:

        UPDATE: aws_s3_bucket.bucket
          acceleration_status:                                            "" => ""
          acl:                                                            "private" => "private"
          arn:                                                            "arn:aws:s3:::tf-test-bucket-3908849865632763027" => "arn:aws:s3:::tf-test-bucket-3908849865632763027"
          bucket:                                                         "tf-test-bucket-3908849865632763027" => "tf-test-bucket-3908849865632763027"
          bucket_domain_name:                                             "tf-test-bucket-3908849865632763027.s3.amazonaws.com" => "tf-test-bucket-3908849865632763027.s3.amazonaws.com"
          bucket_regional_domain_name:                                    "tf-test-bucket-3908849865632763027.s3.us-west-2.amazonaws.com" => "tf-test-bucket-3908849865632763027.s3.us-we
st-2.amazonaws.com"
          cors_rule.#:                                                    "0" => "0"
          force_destroy:                                                  "false" => "false"
          hosted_zone_id:                                                 "Z3BJ6K6RIION7M" => "Z3BJ6K6RIION7M"
          id:                                                             "tf-test-bucket-3908849865632763027" => "tf-test-bucket-3908849865632763027"
          lifecycle_rule.#:                                               "6" => "3"
          lifecycle_rule.0.abort_incomplete_multipart_upload_days:        "0" => "0"
          lifecycle_rule.0.enabled:                                       "true" => "true"
          lifecycle_rule.0.expiration.#:                                  "1" => "0"
          lifecycle_rule.0.expiration.0.date:                             "" => ""
          lifecycle_rule.0.expiration.0.days:                             "365" => ""
          lifecycle_rule.0.expiration.0.expired_object_delete_marker:     "false" => ""
          lifecycle_rule.0.id:                                            "id1" => "id1"
          lifecycle_rule.0.noncurrent_version_expiration.#:               "0" => "1"
          lifecycle_rule.0.noncurrent_version_expiration.0.days:          "" => "365"
          lifecycle_rule.0.noncurrent_version_transition.#:               "0" => "2"
          lifecycle_rule.0.noncurrent_version_transition.0.days:          "" => "30"
          lifecycle_rule.0.noncurrent_version_transition.0.storage_class: "" => "STANDARD_IA"
          lifecycle_rule.0.noncurrent_version_transition.1.days:          "" => "60"
          lifecycle_rule.0.noncurrent_version_transition.1.storage_class: "" => "GLACIER"
          lifecycle_rule.0.prefix:                                        "path1/" => "path1/"
          lifecycle_rule.0.transition.#:                                  "5" => "0"
          lifecycle_rule.0.transition.0.date:                             "" => ""
          lifecycle_rule.0.transition.0.days:                             "210" => ""
          lifecycle_rule.0.transition.0.storage_class:                    "DEEP_ARCHIVE" => ""
          lifecycle_rule.0.transition.1.date:                             "" => ""
          lifecycle_rule.0.transition.1.days:                             "90" => ""
          lifecycle_rule.0.transition.1.storage_class:                    "ONEZONE_IA" => ""
          lifecycle_rule.0.transition.2.date:                             "" => ""
          lifecycle_rule.0.transition.2.days:                             "120" => ""
          lifecycle_rule.0.transition.2.storage_class:                    "GLACIER" => ""
          lifecycle_rule.0.transition.3.date:                             "" => ""
          lifecycle_rule.0.transition.3.days:                             "30" => ""
          lifecycle_rule.0.transition.3.storage_class:                    "STANDARD_IA" => ""
          lifecycle_rule.0.transition.4.date:                             "" => ""
          lifecycle_rule.0.transition.4.days:                             "60" => ""
          lifecycle_rule.0.transition.4.storage_class:                    "INTELLIGENT_TIERING" => ""
          lifecycle_rule.1.abort_incomplete_multipart_upload_days:        "0" => "0"
          lifecycle_rule.1.enabled:                                       "true" => "false"
          lifecycle_rule.1.expiration.#:                                  "1" => "0"
          lifecycle_rule.1.expiration.0.date:                             "2016-01-12" => ""
          lifecycle_rule.1.expiration.0.days:                             "0" => ""
          lifecycle_rule.1.expiration.0.expired_object_delete_marker:     "false" => ""
          lifecycle_rule.1.id:                                            "id2" => "id2"
          lifecycle_rule.1.noncurrent_version_expiration.#:               "0" => "1"
          lifecycle_rule.1.noncurrent_version_expiration.0.days:          "" => "365"
          lifecycle_rule.1.noncurrent_version_transition.#:               "0" => "0"
          lifecycle_rule.1.prefix:                                        "path2/" => "path2/"
          lifecycle_rule.1.transition.#:                                  "0" => "0"
          lifecycle_rule.2.abort_incomplete_multipart_upload_days:        "0" => "0"
          lifecycle_rule.2.enabled:                                       "true" => "true"
          lifecycle_rule.2.expiration.#:                                  "0" => "0"
          lifecycle_rule.2.id:                                            "id3" => "id3"
          lifecycle_rule.2.noncurrent_version_expiration.#:               "0" => "0"
          lifecycle_rule.2.noncurrent_version_transition.#:               "0" => "1"
          lifecycle_rule.2.noncurrent_version_transition.0.days:          "" => "0"
          lifecycle_rule.2.noncurrent_version_transition.0.storage_class: "" => "GLACIER"
          lifecycle_rule.2.prefix:                                        "path3/" => "path3/"
          lifecycle_rule.2.transition.#:                                  "1" => "0"
          lifecycle_rule.2.transition.0.date:                             "" => ""
          lifecycle_rule.2.transition.0.days:                             "0" => ""
          lifecycle_rule.2.transition.0.storage_class:                    "GLACIER" => ""
          lifecycle_rule.3.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.3.enabled:                                       "true" => ""
          lifecycle_rule.3.expiration.#:                                  "1" => ""
          lifecycle_rule.3.expiration.0.date:                             "2016-01-12" => ""
          lifecycle_rule.3.expiration.0.days:                             "0" => ""
          lifecycle_rule.3.expiration.0.expired_object_delete_marker:     "false" => ""
          lifecycle_rule.3.id:                                            "id4" => ""
          lifecycle_rule.3.noncurrent_version_expiration.#:               "0" => ""
          lifecycle_rule.3.noncurrent_version_transition.#:               "0" => ""
          lifecycle_rule.3.prefix:                                        "path4/" => ""
          lifecycle_rule.3.tags.tagKey:                                   "tagValue" => ""
          lifecycle_rule.3.tags.terraform:                                "hashicorp" => ""
          lifecycle_rule.3.transition.#:                                  "0" => ""
          lifecycle_rule.4.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.4.enabled:                                       "true" => ""
          lifecycle_rule.4.expiration.#:                                  "0" => ""
          lifecycle_rule.4.id:                                            "id5" => ""
          lifecycle_rule.4.noncurrent_version_expiration.#:               "0" => ""
          lifecycle_rule.4.noncurrent_version_transition.#:               "0" => ""
          lifecycle_rule.4.prefix:                                        "" => ""
          lifecycle_rule.4.tags.tagKey:                                   "tagValue" => ""
          lifecycle_rule.4.tags.terraform:                                "hashicorp" => ""
          lifecycle_rule.4.transition.#:                                  "1" => ""
          lifecycle_rule.4.transition.0.date:                             "" => ""
          lifecycle_rule.4.transition.0.days:                             "0" => ""
          lifecycle_rule.4.transition.0.storage_class:                    "GLACIER" => ""
          lifecycle_rule.5.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.5.enabled:                                       "true" => ""
          lifecycle_rule.5.expiration.#:                                  "0" => ""
          lifecycle_rule.5.id:                                            "id6" => ""
          lifecycle_rule.5.noncurrent_version_expiration.#:               "0" => ""
          lifecycle_rule.5.noncurrent_version_transition.#:               "0" => ""
          lifecycle_rule.5.prefix:                                        "" => ""
          lifecycle_rule.5.tags.tagKey:                                   "tagValue" => ""
          lifecycle_rule.5.transition.#:                                  "1" => ""
          lifecycle_rule.5.transition.0.date:                             "" => ""
          lifecycle_rule.5.transition.0.days:                             "0" => ""
          lifecycle_rule.5.transition.0.storage_class:                    "GLACIER" => ""
          logging.#:                                                      "0" => "0"
          object_lock_configuration.#:                                    "0" => "0"
          region:                                                         "us-west-2" => "us-west-2"
          replication_configuration.#:                                    "0" => "0"
          request_payer:                                                  "BucketOwner" => "BucketOwner"
          server_side_encryption_configuration.#:                         "0" => "0"
          versioning.#:                                                   "1" => "1"
          versioning.0.enabled:                                           "false" => "false"
          versioning.0.mfa_delete:                                        "false" => "false"
          website.#:                                                      "0" => "0"



        STATE:

        aws_s3_bucket.bucket:
          ID = tf-test-bucket-3908849865632763027
          provider = provider.aws
          acceleration_status =
          acl = private
          arn = arn:aws:s3:::tf-test-bucket-3908849865632763027
          bucket = tf-test-bucket-3908849865632763027
          bucket_domain_name = tf-test-bucket-3908849865632763027.s3.amazonaws.com
          bucket_regional_domain_name = tf-test-bucket-3908849865632763027.s3.us-west-2.amazonaws.com
          force_destroy = false
          hosted_zone_id = Z3BJ6K6RIION7M
          lifecycle_rule.# = 6
          lifecycle_rule.0.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.0.enabled = true
          lifecycle_rule.0.expiration.# = 1
          lifecycle_rule.0.expiration.0.date =
          lifecycle_rule.0.expiration.0.days = 365
          lifecycle_rule.0.expiration.0.expired_object_delete_marker = false
          lifecycle_rule.0.id = id1
          lifecycle_rule.0.prefix = path1/
          lifecycle_rule.0.transition.# = 5
          lifecycle_rule.0.transition.0.date =
          lifecycle_rule.0.transition.0.days = 210
          lifecycle_rule.0.transition.0.storage_class = DEEP_ARCHIVE
          lifecycle_rule.0.transition.1.date =
          lifecycle_rule.0.transition.1.days = 90
          lifecycle_rule.0.transition.1.storage_class = ONEZONE_IA
          lifecycle_rule.0.transition.2.date =
          lifecycle_rule.0.transition.2.days = 120
          lifecycle_rule.0.transition.2.storage_class = GLACIER
          lifecycle_rule.0.transition.3.date =
          lifecycle_rule.0.transition.3.days = 30
          lifecycle_rule.0.transition.3.storage_class = STANDARD_IA
          lifecycle_rule.0.transition.4.date =
          lifecycle_rule.0.transition.4.days = 60
          lifecycle_rule.0.transition.4.storage_class = INTELLIGENT_TIERING
          lifecycle_rule.1.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.1.enabled = true
          lifecycle_rule.1.expiration.# = 1
          lifecycle_rule.1.expiration.0.date = 2016-01-12
          lifecycle_rule.1.expiration.0.days = 0
          lifecycle_rule.1.expiration.0.expired_object_delete_marker = false
          lifecycle_rule.1.id = id2
          lifecycle_rule.1.prefix = path2/
          lifecycle_rule.2.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.2.enabled = true
          lifecycle_rule.2.id = id3
          lifecycle_rule.2.prefix = path3/
          lifecycle_rule.2.transition.# = 1
          lifecycle_rule.2.transition.0.date =
          lifecycle_rule.2.transition.0.days = 0
          lifecycle_rule.2.transition.0.storage_class = GLACIER
          lifecycle_rule.3.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.3.enabled = true
          lifecycle_rule.3.expiration.# = 1
          lifecycle_rule.3.expiration.0.date = 2016-01-12
          lifecycle_rule.3.expiration.0.days = 0
          lifecycle_rule.3.expiration.0.expired_object_delete_marker = false
          lifecycle_rule.3.id = id4
          lifecycle_rule.3.prefix = path4/
          lifecycle_rule.3.tags.tagKey = tagValue
          lifecycle_rule.3.tags.terraform = hashicorp
          lifecycle_rule.4.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.4.enabled = true
          lifecycle_rule.4.id = id5
          lifecycle_rule.4.prefix =
          lifecycle_rule.4.tags.tagKey = tagValue
          lifecycle_rule.4.tags.terraform = hashicorp
          lifecycle_rule.4.transition.# = 1
          lifecycle_rule.4.transition.0.date =
          lifecycle_rule.4.transition.0.days = 0
          lifecycle_rule.4.transition.0.storage_class = GLACIER
          lifecycle_rule.5.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.5.enabled = true
          lifecycle_rule.5.id = id6
          lifecycle_rule.5.prefix =
          lifecycle_rule.5.tags.tagKey = tagValue
          lifecycle_rule.5.transition.# = 1
          lifecycle_rule.5.transition.0.date =
          lifecycle_rule.5.transition.0.days = 0
          lifecycle_rule.5.transition.0.storage_class = GLACIER
          region = us-west-2
          request_payer = BucketOwner
          versioning.# = 1
          versioning.0.enabled = false
          versioning.0.mfa_delete = false
FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       101.090s
make: *** [GNUmakefile:20: testacc] Error 1
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (150.63s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       150.663s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (148.47s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       148.490s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (149.58s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       149.626s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (148.51s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       148.546s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (148.21s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       148.249s
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3Bucket_LifecycleBasic -count=1 -timeout 120m
=== RUN   TestAccAWSS3Bucket_LifecycleBasic
=== PAUSE TestAccAWSS3Bucket_LifecycleBasic
=== CONT  TestAccAWSS3Bucket_LifecycleBasic
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (150.35s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       150.392s
[...]

@pdecat
Copy link
Contributor Author

pdecat commented Apr 20, 2019

Running the same test from master reveals similar issues (the test is named TestAccAWSS3Bucket_Lifecycle in master because I renamed it to TestAccAWSS3Bucket_LifecycleBasic for easier targeting, did not find a easy way to pass the trailing $ to make testacc).

# while true ; do TF_ACC=1 go test ./aws -v -parallel 20 -run='TestAccAWSS3Bucket_Lifecycle$' -count=1 -timeout 120m ; done                                                            
=== RUN   TestAccAWSS3Bucket_Lifecycle
=== PAUSE TestAccAWSS3Bucket_Lifecycle
=== CONT  TestAccAWSS3Bucket_Lifecycle
--- FAIL: TestAccAWSS3Bucket_Lifecycle (84.85s)
    testing.go:568: Step 1 error: Check failed: Check 5/17 error: aws_s3_bucket.bucket: Attribute 'lifecycle_rule.0.noncurrent_version_expiration.80908210.days' not found
FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       84.880s
=== RUN   TestAccAWSS3Bucket_Lifecycle
=== PAUSE TestAccAWSS3Bucket_Lifecycle
=== CONT  TestAccAWSS3Bucket_Lifecycle
        --- PASS: TestAccAWSS3Bucket_Lifecycle (159.00s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       159.041s
=== RUN   TestAccAWSS3Bucket_Lifecycle
=== PAUSE TestAccAWSS3Bucket_Lifecycle
=== CONT  TestAccAWSS3Bucket_Lifecycle
[...]

It looks like the resourceAwsS3BucketLifecycleUpdate() function should wait until the updates are effective on the AWS side.

@pdecat
Copy link
Contributor Author

pdecat commented Apr 20, 2019

Also from master:

=== RUN   TestAccAWSS3Bucket_Lifecycle
=== PAUSE TestAccAWSS3Bucket_Lifecycle
=== CONT  TestAccAWSS3Bucket_Lifecycle
--- FAIL: TestAccAWSS3Bucket_Lifecycle (160.76s)
    testing.go:568: Step 2 error: After applying this step and refreshing, the plan was not empty:

        DIFF:

        UPDATE: aws_s3_bucket.bucket
          acceleration_status:                                            "" => ""
          acl:                                                            "public-read" => "public-read"
          arn:                                                            "arn:aws:s3:::tf-test-bucket-3907504849674326409" => "arn:aws:s3:::tf-test-bucket-3907504849674326409"
          bucket:                                                         "tf-test-bucket-3907504849674326409" => "tf-test-bucket-3907504849674326409"
          bucket_domain_name:                                             "tf-test-bucket-3907504849674326409.s3.amazonaws.com" => "tf-test-bucket-3907504849674326409.s3.amazonaws.com"
          bucket_regional_domain_name:                                    "tf-test-bucket-3907504849674326409.s3.us-west-2.amazonaws.com" => "tf-test-bucket-3907504849674326409.s3.us-we
st-2.amazonaws.com"
          cors_rule.#:                                                    "0" => "0"
          force_destroy:                                                  "false" => "false"
          hosted_zone_id:                                                 "Z3BJ6K6RIION7M" => "Z3BJ6K6RIION7M"
          id:                                                             "tf-test-bucket-3907504849674326409" => "tf-test-bucket-3907504849674326409"
          lifecycle_rule.#:                                               "3" => "0"
          lifecycle_rule.0.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.0.enabled:                                       "true" => ""
          lifecycle_rule.0.expiration.#:                                  "0" => ""
          lifecycle_rule.0.id:                                            "id1" => ""
          lifecycle_rule.0.noncurrent_version_expiration.#:               "1" => ""
          lifecycle_rule.0.noncurrent_version_expiration.0.days:          "365" => ""
          lifecycle_rule.0.noncurrent_version_transition.#:               "2" => ""
          lifecycle_rule.0.noncurrent_version_transition.0.days:          "30" => ""
          lifecycle_rule.0.noncurrent_version_transition.0.storage_class: "STANDARD_IA" => ""
          lifecycle_rule.0.noncurrent_version_transition.1.days:          "60" => ""
          lifecycle_rule.0.noncurrent_version_transition.1.storage_class: "GLACIER" => ""
          lifecycle_rule.0.prefix:                                        "path1/" => ""
          lifecycle_rule.0.transition.#:                                  "0" => ""
          lifecycle_rule.1.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.1.enabled:                                       "false" => ""
          lifecycle_rule.1.expiration.#:                                  "0" => ""
          lifecycle_rule.1.id:                                            "id2" => ""
          lifecycle_rule.1.noncurrent_version_expiration.#:               "1" => ""
          lifecycle_rule.1.noncurrent_version_expiration.0.days:          "365" => ""
          lifecycle_rule.1.noncurrent_version_transition.#:               "0" => ""
          lifecycle_rule.1.prefix:                                        "path2/" => ""
          lifecycle_rule.1.transition.#:                                  "0" => ""
          lifecycle_rule.2.abort_incomplete_multipart_upload_days:        "0" => ""
          lifecycle_rule.2.enabled:                                       "true" => ""
          lifecycle_rule.2.expiration.#:                                  "0" => ""
          lifecycle_rule.2.id:                                            "id3" => ""
          lifecycle_rule.2.noncurrent_version_expiration.#:               "0" => ""
          lifecycle_rule.2.noncurrent_version_transition.#:               "1" => ""
          lifecycle_rule.2.noncurrent_version_transition.0.days:          "0" => ""
          lifecycle_rule.2.noncurrent_version_transition.0.storage_class: "GLACIER" => ""
          lifecycle_rule.2.prefix:                                        "path3/" => ""
          lifecycle_rule.2.transition.#:                                  "0" => ""
          logging.#:                                                      "0" => "0"
          object_lock_configuration.#:                                    "0" => "0"
          region:                                                         "us-west-2" => "us-west-2"
          replication_configuration.#:                                    "0" => "0"
          request_payer:                                                  "BucketOwner" => "BucketOwner"
          server_side_encryption_configuration.#:                         "0" => "0"
          versioning.#:                                                   "1" => "1"
          versioning.0.enabled:                                           "false" => "false"
          versioning.0.mfa_delete:                                        "false" => "false"
          website.#:                                                      "0" => "0"



        STATE:

        aws_s3_bucket.bucket:
          ID = tf-test-bucket-3907504849674326409
          provider = provider.aws
          acceleration_status =
          acl = public-read
          arn = arn:aws:s3:::tf-test-bucket-3907504849674326409
          bucket = tf-test-bucket-3907504849674326409
          bucket_domain_name = tf-test-bucket-3907504849674326409.s3.amazonaws.com
          bucket_regional_domain_name = tf-test-bucket-3907504849674326409.s3.us-west-2.amazonaws.com
          force_destroy = false
          hosted_zone_id = Z3BJ6K6RIION7M
          lifecycle_rule.# = 3
          lifecycle_rule.0.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.0.enabled = true
          lifecycle_rule.0.id = id1
          lifecycle_rule.0.noncurrent_version_expiration.# = 1
          lifecycle_rule.0.noncurrent_version_expiration.0.days = 365
          lifecycle_rule.0.noncurrent_version_transition.# = 2
          lifecycle_rule.0.noncurrent_version_transition.0.days = 30
          lifecycle_rule.0.noncurrent_version_transition.0.storage_class = STANDARD_IA
          lifecycle_rule.0.noncurrent_version_transition.1.days = 60
          lifecycle_rule.0.noncurrent_version_transition.1.storage_class = GLACIER
          lifecycle_rule.0.prefix = path1/
          lifecycle_rule.1.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.1.enabled = false
          lifecycle_rule.1.id = id2
          lifecycle_rule.1.noncurrent_version_expiration.# = 1
          lifecycle_rule.1.noncurrent_version_expiration.0.days = 365
          lifecycle_rule.1.prefix = path2/
          lifecycle_rule.2.abort_incomplete_multipart_upload_days = 0
          lifecycle_rule.2.enabled = true
          lifecycle_rule.2.id = id3
          lifecycle_rule.2.noncurrent_version_transition.# = 1
          lifecycle_rule.2.noncurrent_version_transition.0.days = 0
          lifecycle_rule.2.noncurrent_version_transition.0.storage_class = GLACIER
          lifecycle_rule.2.prefix = path3/
          region = us-west-2
          request_payer = BucketOwner
          versioning.# = 1
          versioning.0.enabled = false
          versioning.0.mfa_delete = false
FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       160.793s

@pdecat
Copy link
Contributor Author

pdecat commented Apr 20, 2019

Here's a complete debug output when it is failing on master: https://gist.github.com/pdecat/8a74f9b2a8d3bc1fd075b747f1e15549

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 894704f to a59152e Compare May 6, 2019 19:49
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from a59152e to 4f9273c Compare May 23, 2019 09:08
@pdecat
Copy link
Contributor Author

pdecat commented Jun 13, 2019

Rebased on master to resolve conflicts.

@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch 2 times, most recently from 9f0b8ae to 64a012e Compare June 19, 2019 11:24
@aeschright aeschright requested a review from a team June 25, 2019 22:09
@pdecat pdecat force-pushed the fix-s3-bucket-lifecycle-filter-tags branch from 64a012e to 9a69443 Compare July 10, 2019 07:27
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

Hi @pdecat this looks good. It's such a subtle issue so thank you for calling out the edge case and going into detail within the original issue.

It is a bit of work to add an acceptance test that creates a lifecycle rule with a single tag and no prefix given our current implementation so it's okay to leave out. The updated test validates that the added logic works expected so that is a good step forward. I also validated that all other tests pass as expected prior to the approval. Thanks again.

@nywilken nywilken added this to the v2.19.0 milestone Jul 10, 2019
@nywilken nywilken merged commit c15f23b into hashicorp:master Jul 10, 2019
@nywilken nywilken added the bug Addresses a defect in current functionality. label Jul 10, 2019
nywilken added a commit that referenced this pull request Jul 10, 2019
@pdecat pdecat deleted the fix-s3-bucket-lifecycle-filter-tags branch July 10, 2019 20:43
@pdecat
Copy link
Contributor Author

pdecat commented Jul 10, 2019

Thanks @nywilken!

@bflad
Copy link
Contributor

bflad commented Jul 11, 2019

This has been released in version 2.19.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 2, 2019

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 Nov 2, 2019
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. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

s3: Ignored lifecycle_policy is changed anyway
3 participants