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

resource/aws_cloudfront_distribution: TestAccAWSCloudFrontDistribution_OriginGroups Test Failures #14809

Closed
bflad opened this issue Aug 24, 2020 · 3 comments · Fixed by #14844
Assignees
Labels
service/cloudfront Issues and PRs that pertain to the cloudfront 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 Aug 24, 2020

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

Likely due to the upgrade to Terraform Plugin SDK version 2, the following test is now consistently failing:

=== CONT  TestAccAWSCloudFrontDistribution_OriginGroups
TestAccAWSCloudFrontDistribution_OriginGroups: resource_aws_cloudfront_distribution_test.go:1084: Check 3/3 error: "aws_cloudfront_distribution.failover_distribution" no TypeSet element "origin_group.*", with nested attrs map[string]string{"failover_criteria.#":"1", "failover_criteria.0.status_codes.#":"4", "failover_criteria.0.status_codes.1057413486":"403", "failover_criteria.0.status_codes.1883721641":"404", "failover_criteria.0.status_codes.2661388106":"502", "failover_criteria.0.status_codes.2895637960":"500", "member.#":"2", "member.0.origin_id":"primaryS3", "member.1.origin_id":"failoverS3", "origin_id":"groupS3"} in state: map[string]string{"%":"29", "arn":"arn:aws:cloudfront::*******:distribution/E1SLBJVOF39F1G", "caller_reference":"terraform-20200824035613548800000001", "custom_error_response.#":"0", "default_cache_behavior.#":"1", "default_cache_behavior.0.%":"13", "default_cache_behavior.0.allowed_methods.#":"2", "default_cache_behavior.0.allowed_methods.0":"GET", "default_cache_behavior.0.allowed_methods.1":"HEAD", "default_cache_behavior.0.cached_methods.#":"2", "default_cache_behavior.0.cached_methods.0":"GET", "default_cache_behavior.0.cached_methods.1":"HEAD", "default_cache_behavior.0.compress":"false", "default_cache_behavior.0.default_ttl":"86400", "default_cache_behavior.0.field_level_encryption_id":"", "default_cache_behavior.0.forwarded_values.#":"1", "default_cache_behavior.0.forwarded_values.0.%":"4", "default_cache_behavior.0.forwarded_values.0.cookies.#":"1", "default_cache_behavior.0.forwarded_values.0.cookies.0.%":"2", "default_cache_behavior.0.forwarded_values.0.cookies.0.forward":"none", "default_cache_behavior.0.forwarded_values.0.query_string":"false", "default_cache_behavior.0.lambda_function_association.#":"0", "default_cache_behavior.0.max_ttl":"31536000", "default_cache_behavior.0.min_ttl":"0", "default_cache_behavior.0.smooth_streaming":"false", "default_cache_behavior.0.target_origin_id":"groupS3", "default_cache_behavior.0.viewer_protocol_policy":"allow-all", "default_root_object":"", "domain_name":"d34ynqiy0mie7m.cloudfront.net", "enabled":"true", "etag":"E2DJ72VD6FAT9Z", "hosted_zone_id":"Z2FDTNDATAQYW2", "http_version":"http2", "id":"E1SLBJVOF39F1G", "in_progress_validation_batches":"0", "is_ipv6_enabled":"false", "last_modified_time":"2020-08-24 03:56:13.909 +0000 UTC", "logging_config.#":"0", "ordered_cache_behavior.#":"0", "origin.#":"2", "origin.0.%":"6", "origin.0.custom_header.#":"0", "origin.0.custom_origin_config.#":"0", "origin.0.domain_name":"mybucket-backup.1492864405643712602.s3.us-west-2.amazonaws.com", "origin.0.origin_id":"failoverS3", "origin.0.origin_path":"", "origin.0.s3_origin_config.#":"0", "origin.1.%":"6", "origin.1.custom_header.#":"0", "origin.1.custom_origin_config.#":"0", "origin.1.domain_name":"mybucket.1492864405643712602.s3.us-west-2.amazonaws.com", "origin.1.origin_id":"primaryS3", "origin.1.origin_path":"", "origin.1.s3_origin_config.#":"0", "origin_group.#":"1", "origin_group.0.%":"3", "origin_group.0.failover_criteria.#":"1", "origin_group.0.failover_criteria.0.%":"1", "origin_group.0.failover_criteria.0.status_codes.#":"4", "origin_group.0.failover_criteria.0.status_codes.0":"403", "origin_group.0.failover_criteria.0.status_codes.1":"404", "origin_group.0.failover_criteria.0.status_codes.2":"500", "origin_group.0.failover_criteria.0.status_codes.3":"502", "origin_group.0.member.#":"2", "origin_group.0.member.0.%":"1", "origin_group.0.member.0.origin_id":"primaryS3", "origin_group.0.member.1.%":"1", "origin_group.0.member.1.origin_id":"failoverS3", "origin_group.0.origin_id":"groupS3", "price_class":"PriceClass_All", "restrictions.#":"1", "restrictions.0.%":"1", "restrictions.0.geo_restriction.#":"1", "restrictions.0.geo_restriction.0.%":"2", "restrictions.0.geo_restriction.0.locations.#":"4", "restrictions.0.geo_restriction.0.locations.0":"CA", "restrictions.0.geo_restriction.0.locations.1":"DE", "restrictions.0.geo_restriction.0.locations.2":"GB", "restrictions.0.geo_restriction.0.locations.3":"US", "restrictions.0.geo_restriction.0.restriction_type":"whitelist", "retain_on_delete":"false", "status":"Deployed", "trusted_signers.#":"1", "trusted_signers.0.%":"2", "trusted_signers.0.enabled":"false", "trusted_signers.0.items.#":"0", "viewer_certificate.#":"1", "viewer_certificate.0.%":"5", "viewer_certificate.0.acm_certificate_arn":"", "viewer_certificate.0.cloudfront_default_certificate":"true", "viewer_certificate.0.iam_certificate_id":"", "viewer_certificate.0.minimum_protocol_version":"TLSv1", "viewer_certificate.0.ssl_support_method":"", "wait_for_deployment":"true", "web_acl_id":""}
--- FAIL: TestAccAWSCloudFrontDistribution_OriginGroups (412.27s)

It might be clearer to see what is potentially happening here by looking at the test code itself:

					tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "origin_group.*", map[string]string{
						"origin_id":                                   "groupS3",
						"failover_criteria.#":                         "1",
						"failover_criteria.0.status_codes.#":          "4",
						"failover_criteria.0.status_codes.1057413486": "403",
						"failover_criteria.0.status_codes.1883721641": "404",
						"failover_criteria.0.status_codes.2661388106": "502",
						"failover_criteria.0.status_codes.2895637960": "500",
						"member.#":           "2",
						"member.0.origin_id": "primaryS3",
						"member.1.origin_id": "failoverS3",
					}),

Version 2 of the SDK no longer supports those nested attribute hashes at all. Removing those lines with the specific status codes and/or creating a separate lookup (untested example below) may work.

					tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "origin_group.*", map[string]string{
						"origin_id":                          "groupS3",
						"failover_criteria.#":                "1",
						"failover_criteria.0.status_codes.#": "4",
						"member.#":                           "2",
						"member.0.origin_id":                 "primaryS3",
						"member.1.origin_id":                 "failoverS3",
					}),
					tfawsresource.TestCheckTypeSetElemAttr(resourceName, "origin_group.*.failover_criteria.0.status_codes.*", "403"),
					tfawsresource.TestCheckTypeSetElemAttr(resourceName, "origin_group.*.failover_criteria.0.status_codes.*", "404"),
					tfawsresource.TestCheckTypeSetElemAttr(resourceName, "origin_group.*.failover_criteria.0.status_codes.*", "500"),
					tfawsresource.TestCheckTypeSetElemAttr(resourceName, "origin_group.*.failover_criteria.0.status_codes.*", "502"),

Affected Resources

  • aws_cloudfront_distribution

Affected Tests

  • TestAccAWSCloudFrontDistribution_OriginGroups

References

@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 Aug 24, 2020
@bflad bflad added this to the Roadmap milestone Aug 24, 2020
@ewbankkit ewbankkit self-assigned this Aug 26, 2020
@anGie44 anGie44 modified the milestones: Roadmap, v3.4.0 Aug 26, 2020
@anGie44
Copy link
Contributor

anGie44 commented Aug 26, 2020

The fix for this has been merged and will release with version 3.4.0 of the Terraform AWS Provider, likely out tomorrow.

@ghost
Copy link

ghost commented Aug 27, 2020

This has been released in version 3.4.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 Sep 26, 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 Sep 26, 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. 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
3 participants