Skip to content

Commit

Permalink
tests/resource/aws_cloudfront_distribution: Add aws_s3_bucket resourc…
Browse files Browse the repository at this point in the history
…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)
```
  • Loading branch information
bflad committed Mar 15, 2021
1 parent b4205b9 commit 3c386db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions aws/resource_aws_cloudfront_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1248,8 +1248,9 @@ resource "aws_s3_bucket" "s3_backup_bucket_origin" {

var logBucket = `
resource "aws_s3_bucket" "s3_bucket_logs" {
bucket = "mylogs.${var.rand_id}"
acl = "public-read"
acl = "public-read"
bucket = "mylogs.${var.rand_id}"
force_destroy = true
}
`

Expand Down
5 changes: 3 additions & 2 deletions aws/resource_aws_msk_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,9 @@ resource "aws_cloudwatch_log_group" "test" {
}
resource "aws_s3_bucket" "bucket" {
bucket = %[1]q
acl = "private"
acl = "private"
bucket = %[1]q
force_destroy = true
}
resource "aws_iam_role" "firehose_role" {
Expand Down
1 change: 1 addition & 0 deletions docs/contributing/running-and-writing-acceptance-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ The below are required items that will be noted during submission review and pre
- [ ] __Uses resource.ParallelTest__: Tests should utilize [`resource.ParallelTest()`](https://godoc.org/github.com/hashicorp/terraform/helper/resource#ParallelTest) instead of [`resource.Test()`](https://godoc.org/github.com/hashicorp/terraform/helper/resource#Test) except where serialized testing is absolutely required.
- [ ] __Uses fmt.Sprintf()__: Test configurations preferably should to be separated into their own functions (typically named `testAccAws{SERVICE}{RESOURCE}Config{PURPOSE}`) that call [`fmt.Sprintf()`](https://golang.org/pkg/fmt/#Sprintf) for variable injection or a string `const` for completely static configurations. Test configurations should avoid `var` or other variable injection functionality such as [`text/template`](https://golang.org/pkg/text/template/).
- [ ] __Uses Randomized Infrastructure Naming__: Test configurations that utilize resources where a unique name is required should generate a random name. Typically this is created via `rName := acctest.RandomWithPrefix("tf-acc-test")` in the acceptance test function before generating the configuration.
- [ ] __Prevents S3 Bucket Deletion Errors__: Test configurations that utilize `aws_s3_bucket` resources as a logging destination should include the `force_destroy = true` configuration. This is to prevent race conditions where logging objects may be written during the testing duration which will cause `BucketNotEmpty` errors during deletion.

For resources that support import, the additional item below is required that will be noted during submission review and prevent immediate merging:

Expand Down

0 comments on commit 3c386db

Please sign in to comment.