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: Remove extraneous aliases configurations and create aliased us-east-1 provider configuration #8314

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Apr 15, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

On April 8th, 2019, Amazon CloudFront began validating alternate domain names for security reasons. Some of our acceptance testing was extraneously assigning aliases to CloudFront distributions configured with the CloudFront default certificate and began failing as a result of this service update.

Previous output from acceptance testing:

--- FAIL: TestAccAWSCloudFrontDistribution_S3Origin (95.64s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

--- FAIL: TestAccAWSCloudFrontDistribution_S3OriginWithTags (95.90s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

--- FAIL: TestAccAWSCloudFrontDistribution_customOrigin (65.61s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.custom_distribution: 1 error occurred:
          * aws_cloudfront_distribution.custom_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

--- FAIL: TestAccAWSCloudFrontDistribution_multiOrigin (95.68s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.multi_origin_distribution: 1 error occurred:
          * aws_cloudfront_distribution.multi_origin_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

This change simply removes the aws_cloudfront_distribution resource aliases configurations, which are not meaningful in these acceptance tests. We also remove the hardcoded us-east-1 region provider used for ACM certificate handling as it can break other acceptance testing when run concurrently (e.g. locally with go test -parallel):

--- FAIL: TestAccAWSCloudFrontDistribution_OriginGroups (1247.64s)
    testing.go:599: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: Error applying: 2 errors occurred:
          * aws_s3_bucket.s3_bucket_origin (destroy): 1 error occurred:
          * aws_s3_bucket.s3_bucket_origin: error deleting S3 Bucket (mybucket.6479347118024743098): BucketRegionError: incorrect region, the bucket is not in 'us-east-1' region at endpoint ''
          status code: 301, request id: , host id:

          * aws_s3_bucket.s3_backup_bucket_origin (destroy): 1 error occurred:
          * aws_s3_bucket.s3_backup_bucket_origin: error deleting S3 Bucket (mybucket-backup.6479347118024743098): BucketRegionError: incorrect region, the bucket is not in 'us-east-1' region at endpoint ''
          status code: 301, request id: , host id:

The aliased us-east-1 provider configuration will be applied to other test configuration usage later.

Output from acceptance testing:

--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (2.11s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (2.21s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (590.42s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (592.18s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (592.31s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (592.72s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (594.33s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (1187.55s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (1187.67s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (1225.22s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (1225.58s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (1226.33s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (1227.19s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (1229.81s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (1230.36s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (1232.47s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (1232.59s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (1231.23s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (1233.12s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (1234.68s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (1728.08s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (1787.54s)

… configurations and create aliased us-east-1 provider configuration

On April 8th, 2019, [Amazon CloudFront began validating alternate domain names](https://aws.amazon.com/about-aws/whats-new/2019/04/amazon-cloudfront-enhances-the-security-for-adding-alternate-domain-names-to-a-distribution/) for security reasons. Some of our acceptance testing was extraneously assigning aliases to CloudFront distributions configured with the CloudFront default certificate and began failing as a result of this service update.

Previous output from acceptance testing:

```
--- FAIL: TestAccAWSCloudFrontDistribution_S3Origin (95.64s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

--- FAIL: TestAccAWSCloudFrontDistribution_S3OriginWithTags (95.90s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: 1 error occurred:
          * aws_cloudfront_distribution.s3_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

--- FAIL: TestAccAWSCloudFrontDistribution_customOrigin (65.61s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.custom_distribution: 1 error occurred:
          * aws_cloudfront_distribution.custom_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements

--- FAIL: TestAccAWSCloudFrontDistribution_multiOrigin (95.68s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
          * aws_cloudfront_distribution.multi_origin_distribution: 1 error occurred:
          * aws_cloudfront_distribution.multi_origin_distribution: error creating CloudFront Distribution: InvalidViewerCertificate: To add an alternate domain name (CNAME) to a CloudFront distribution, you must attach a trusted certificate that validates your authorization to use the domain name. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements
```

This change simply removes the `aws_cloudfront_distribution` resource `aliases` configurations, which are not meaningful in these acceptance tests. We also remove the hardcoded `us-east-1` region provider used for ACM certificate handling as it can break other acceptance testing when run concurrently (e.g. locally with `go test -parallel`):

```
--- FAIL: TestAccAWSCloudFrontDistribution_OriginGroups (1247.64s)
    testing.go:599: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: Error applying: 2 errors occurred:
          * aws_s3_bucket.s3_bucket_origin (destroy): 1 error occurred:
          * aws_s3_bucket.s3_bucket_origin: error deleting S3 Bucket (mybucket.6479347118024743098): BucketRegionError: incorrect region, the bucket is not in 'us-east-1' region at endpoint ''
          status code: 301, request id: , host id:

          * aws_s3_bucket.s3_backup_bucket_origin (destroy): 1 error occurred:
          * aws_s3_bucket.s3_backup_bucket_origin: error deleting S3 Bucket (mybucket-backup.6479347118024743098): BucketRegionError: incorrect region, the bucket is not in 'us-east-1' region at endpoint ''
          status code: 301, request id: , host id:
```

The aliased `us-east-1` provider configuration will be applied to other test configuration usage later.

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (2.11s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (2.21s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (590.42s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (592.18s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (592.31s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (592.72s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (594.33s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (1187.55s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (1187.67s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (1225.22s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (1225.58s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (1226.33s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (1227.19s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (1229.81s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (1230.36s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (1232.47s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (1232.59s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (1231.23s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (1233.12s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (1234.68s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (1728.08s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (1787.54s)
```
@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. labels Apr 15, 2019
@bflad bflad requested a review from a team April 15, 2019 15:17
@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Apr 15, 2019
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.

LGTM 👍 👍

@nywilken nywilken merged commit 89aec29 into master Apr 26, 2019
@nywilken nywilken deleted the td-aws_cloudfront_distribution-alias-verification branch April 26, 2019 15:16
@ghost
Copy link

ghost commented Mar 30, 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 Mar 30, 2020
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. 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.

2 participants