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

tests/resource/aws_cloudfront_distribution: BucketNotEmpty Errors #18093

Closed
bflad opened this issue Mar 15, 2021 · 2 comments · Fixed by #18096
Closed

tests/resource/aws_cloudfront_distribution: BucketNotEmpty Errors #18093

bflad opened this issue Mar 15, 2021 · 2 comments · Fixed by #18096
Labels
service/cloudfront Issues and PRs that pertain to the cloudfront service. service/s3 Issues and PRs that pertain to the s3 service. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Mar 15, 2021

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

Description

The following testing is showing errors related non-empty S3 Buckets:

=== CONT  TestAccAWSCloudFrontDistribution_originPolicyOrdered
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.2357952446407137479): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: MPKM026WH6589YVB, host id: lht+Qof4FYrYfdN/8GtjzeaAjoOsZ6aj69agmshQhUJyxNMoFnU6K6cLGU8eR53nV9e4q8nD0H8=
--- FAIL: TestAccAWSCloudFrontDistribution_originPolicyOrdered (343.36s)

=== CONT  TestAccAWSCloudFrontDistribution_S3Origin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.3372655815263830900): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: XE65MK42EWF6Y4CN, host id: Lrn6YBKiBDwkzn+ge4i7QHa5kzaZOazWHAG899H7tzWpWQoLutfr1VM3HoSPXPGihNvEfRYsmJ8=
--- FAIL: TestAccAWSCloudFrontDistribution_S3Origin (405.80s)

=== CONT  TestAccAWSCloudFrontDistribution_multiOrigin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.3276133232211037586): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: XE64PFJ4MXABGV9D, host id: iV0ph9Kutj5Sjb+lGfulrXTh/HMowzHzHwtjG1+h9leJ1uvnDFIxA6ZCwe1BJJrH3h4UU0TAxb4=
--- FAIL: TestAccAWSCloudFrontDistribution_multiOrigin (377.78s)

=== CONT  TestAccAWSCloudFrontDistribution_customOrigin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.513520244091798268): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: 96KBJSB2W4DTE8XQ, host id: irsAvk26kB0RehhtFu2kfYz7gOZGNrGVgwy2PRhZlRagE9cgePqsN75xJ64M2/WXB26Il7VHPak=
--- FAIL: TestAccAWSCloudFrontDistribution_customOrigin (399.82s)

=== CONT  TestAccAWSCloudFrontDistribution_originPolicyDefault
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.7021845477121765752): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: 96K02Y0K8CYDH6SS, host id: /jR8/SGpMVR8T+mApYmB66cqcoJqgxPYeMvUYDUthRvlonhGj5PVIsF2MdWRRKXSBc/IsLNd4WU=
--- FAIL: TestAccAWSCloudFrontDistribution_originPolicyDefault (386.06s)

Since the objects in the S3 Bucket are outside the control of the Terraform configuration, it is expected to enable force_destroy = true on these aws_s3_bucket managed resources for this testing. While we are adjusting this configuration, it is probably best to also set the ACL to private.

Affected Resource

  • aws_cloudfront_distribution

Potential Terraform Configuration

Quickest fix:

resource "aws_s3_bucket" "s3_bucket_logs" {
  acl           = "public-read"
  bucket        = "mylogs.${var.rand_id}"
  force_destroy = true
}
@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/cloudfront Issues and PRs that pertain to the cloudfront service. technical-debt Addresses areas of the codebase that need refactoring or redesign. labels Mar 15, 2021
@ghost ghost added the service/s3 Issues and PRs that pertain to the s3 service. label Mar 15, 2021
bflad added a commit that referenced this issue Mar 15, 2021
…e force_destroy argument in log bucket configurations

Reference: #18093
Reference: #18094

Previously:

```
=== CONT  TestAccAWSCloudFrontDistribution_originPolicyOrdered
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.2357952446407137479): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: MPKM026WH6589YVB, host id: lht+Qof4FYrYfdN/8GtjzeaAjoOsZ6aj69agmshQhUJyxNMoFnU6K6cLGU8eR53nV9e4q8nD0H8=
--- FAIL: TestAccAWSCloudFrontDistribution_originPolicyOrdered (343.36s)

=== CONT  TestAccAWSCloudFrontDistribution_S3Origin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.3372655815263830900): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: XE65MK42EWF6Y4CN, host id: Lrn6YBKiBDwkzn+ge4i7QHa5kzaZOazWHAG899H7tzWpWQoLutfr1VM3HoSPXPGihNvEfRYsmJ8=
--- FAIL: TestAccAWSCloudFrontDistribution_S3Origin (405.80s)

=== CONT  TestAccAWSCloudFrontDistribution_multiOrigin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.3276133232211037586): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: XE64PFJ4MXABGV9D, host id: iV0ph9Kutj5Sjb+lGfulrXTh/HMowzHzHwtjG1+h9leJ1uvnDFIxA6ZCwe1BJJrH3h4UU0TAxb4=
--- FAIL: TestAccAWSCloudFrontDistribution_multiOrigin (377.78s)

=== CONT  TestAccAWSCloudFrontDistribution_customOrigin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.513520244091798268): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: 96KBJSB2W4DTE8XQ, host id: irsAvk26kB0RehhtFu2kfYz7gOZGNrGVgwy2PRhZlRagE9cgePqsN75xJ64M2/WXB26Il7VHPak=
--- FAIL: TestAccAWSCloudFrontDistribution_customOrigin (399.82s)

=== CONT  TestAccAWSCloudFrontDistribution_originPolicyDefault
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.7021845477121765752): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: 96K02Y0K8CYDH6SS, host id: /jR8/SGpMVR8T+mApYmB66cqcoJqgxPYeMvUYDUthRvlonhGj5PVIsF2MdWRRKXSBc/IsLNd4WU=
--- FAIL: TestAccAWSCloudFrontDistribution_originPolicyDefault (386.06s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (367.76s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (190.05s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (247.83s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_RealtimeLogConfigArn (243.37s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (190.48s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (197.40s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (557.82s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (347.99s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (351.98s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (366.99s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (347.64s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (347.64s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (371.75s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (187.25s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (192.30s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_RealtimeLogConfigArn (238.96s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehaviorCachePolicy (394.25s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (0.89s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (4.48s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (389.83s)
--- PASS: TestAccAWSCloudFrontDistribution_originPolicyDefault (400.43s)
--- PASS: TestAccAWSCloudFrontDistribution_originPolicyOrdered (368.67s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (371.51s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (355.44s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (552.18s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (201.80s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (236.43s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (385.55s)

--- PASS: TestAccAWSMskCluster_LoggingInfo (1690.65s)
```
bflad added a commit that referenced this issue Mar 18, 2021
…log bucket configurations (#18096)

* tests/resource/aws_cloudfront_distribution: Add aws_s3_bucket resource force_destroy argument in log bucket configurations

Reference: #18093
Reference: #18094

Previously:

```
=== CONT  TestAccAWSCloudFrontDistribution_originPolicyOrdered
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.2357952446407137479): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: MPKM026WH6589YVB, host id: lht+Qof4FYrYfdN/8GtjzeaAjoOsZ6aj69agmshQhUJyxNMoFnU6K6cLGU8eR53nV9e4q8nD0H8=
--- FAIL: TestAccAWSCloudFrontDistribution_originPolicyOrdered (343.36s)

=== CONT  TestAccAWSCloudFrontDistribution_S3Origin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.3372655815263830900): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: XE65MK42EWF6Y4CN, host id: Lrn6YBKiBDwkzn+ge4i7QHa5kzaZOazWHAG899H7tzWpWQoLutfr1VM3HoSPXPGihNvEfRYsmJ8=
--- FAIL: TestAccAWSCloudFrontDistribution_S3Origin (405.80s)

=== CONT  TestAccAWSCloudFrontDistribution_multiOrigin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.3276133232211037586): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: XE64PFJ4MXABGV9D, host id: iV0ph9Kutj5Sjb+lGfulrXTh/HMowzHzHwtjG1+h9leJ1uvnDFIxA6ZCwe1BJJrH3h4UU0TAxb4=
--- FAIL: TestAccAWSCloudFrontDistribution_multiOrigin (377.78s)

=== CONT  TestAccAWSCloudFrontDistribution_customOrigin
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.513520244091798268): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: 96KBJSB2W4DTE8XQ, host id: irsAvk26kB0RehhtFu2kfYz7gOZGNrGVgwy2PRhZlRagE9cgePqsN75xJ64M2/WXB26Il7VHPak=
--- FAIL: TestAccAWSCloudFrontDistribution_customOrigin (399.82s)

=== CONT  TestAccAWSCloudFrontDistribution_originPolicyDefault
testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
Error: error deleting S3 Bucket (mylogs.7021845477121765752): BucketNotEmpty: The bucket you tried to delete is not empty
  status code: 409, request id: 96K02Y0K8CYDH6SS, host id: /jR8/SGpMVR8T+mApYmB66cqcoJqgxPYeMvUYDUthRvlonhGj5PVIsF2MdWRRKXSBc/IsLNd4WU=
--- FAIL: TestAccAWSCloudFrontDistribution_originPolicyDefault (386.06s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (367.76s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (190.05s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (247.83s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_RealtimeLogConfigArn (243.37s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (190.48s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (197.40s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (557.82s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (347.99s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (351.98s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (366.99s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (347.64s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (347.64s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (371.75s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (187.25s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (192.30s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_RealtimeLogConfigArn (238.96s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehaviorCachePolicy (394.25s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (0.89s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (4.48s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (389.83s)
--- PASS: TestAccAWSCloudFrontDistribution_originPolicyDefault (400.43s)
--- PASS: TestAccAWSCloudFrontDistribution_originPolicyOrdered (368.67s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (371.51s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (355.44s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (552.18s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (201.80s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (236.43s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (385.55s)

--- PASS: TestAccAWSMskCluster_LoggingInfo (1690.65s)
```

* tests/resource/aws_globalaccelerator_accelerator: Add force_destroy to aws_s3_bucket resource in test configuration

Reference: #18121

Previously:

```
Error: error deleting S3 Bucket (tf-acc-test-8066618524275417147): BucketNotEmpty: The bucket you tried to delete is not empty
	status code: 409

--- FAIL: TestAccAwsGlobalAcceleratorAccelerator_attributes (519.52s)
```

Output from acceptance testing:

```
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_attributes (364.11s)
```
@github-actions github-actions bot added this to the v3.33.0 milestone Mar 18, 2021
@ghost
Copy link

ghost commented Mar 18, 2021

This has been released in version 3.33.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 Apr 18, 2021

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 as resolved and limited conversation to collaborators Apr 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/cloudfront Issues and PRs that pertain to the cloudfront service. service/s3 Issues and PRs that pertain to the s3 service. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
1 participant