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 missing default value in cloudfront_distribution's origin.origin_path #20709

Merged
merged 1 commit into from
Mar 25, 2022

Conversation

kyontan
Copy link
Contributor

@kyontan kyontan commented Aug 27, 2021

The default value of origin_path parameter in origin block is blank string (""), not null.
It is known problem in #12065. The workaround is described in the issue.
Without this PR, modifing aws_cloudfront_distrtibution will crash and state get broken.

It is apparently a bug in the provider and it should be handled by provider.

I have confirmed CLI (aws cloudfront get-distribution) returns blank string ("") as default value if create resource without setting origin_path explicitly.

According to the document, the default value is not noted though.
https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_Origin.html

This problem is work-arounded jmgreg31/terraform-aws-cloudfront#38.

Relates: #12065

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" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSCloudFrontDistribution*'
==> Checking that code complies with gofmt requirements...

TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSCloudFrontDistribution* -timeout 180m
(RUN, PAUSE, and CONT are omitted)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (84.70s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (88.44s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (378.55s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (381.56s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedKeyGroups (425.97s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (430.12s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_RealtimeLogConfigArn (435.36s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_RealtimeLogConfigArn (442.50s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (455.09s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (483.63s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (504.55s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (559.72s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (560.71s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (565.85s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (567.32s)
--- PASS: TestAccAWSCloudFrontDistribution_originPolicyOrdered (482.98s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehaviorCachePolicy (480.73s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_ConnectionTimeout (610.52s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_ConnectionAttempts (610.79s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_OriginShield (611.74s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (236.41s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (265.15s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (306.66s)
--- PASS: TestAccAWSCloudFrontDistribution_forwardedValuesToCachePolicy (751.16s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (392.02s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (473.06s)
--- PASS: TestAccAWSCloudFrontDistribution_originPolicyDefault (469.09s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (479.67s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (905.76s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (531.50s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (374.37s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (449.19s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (577.89s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       1086.053s

@github-actions github-actions bot added service/cloudfront Issues and PRs that pertain to the cloudfront service. needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. and removed service/cloudfront Issues and PRs that pertain to the cloudfront service. labels Aug 27, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @kyontan 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@github-actions github-actions bot added the service/cloudfront Issues and PRs that pertain to the cloudfront service. label Aug 27, 2021
@kyontan kyontan changed the title [WIP] Set properly default value of origin_path in cloudfront_distribution's origin Set properly default value of origin_path in cloudfront_distribution's origin Aug 27, 2021
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Aug 27, 2021
@kyontan kyontan changed the title Set properly default value of origin_path in cloudfront_distribution's origin Fix default value in cloudfront_distribution's origin.origin_path Aug 30, 2021
@kyontan
Copy link
Contributor Author

kyontan commented Sep 3, 2021

We have ran the acceptance tests and confirmed no regression found.

@kyontan
Copy link
Contributor Author

kyontan commented Sep 3, 2021

@breathingdust Could you see this pr? Thanks.

@kyontan kyontan changed the title Fix default value in cloudfront_distribution's origin.origin_path [CRITICAL] Fix default value in cloudfront_distribution's origin.origin_path Sep 13, 2021
@kyontan
Copy link
Contributor Author

kyontan commented Sep 13, 2021

@ewbankkit @DrFaust92 Could you take a look for this pr?
Our environment's tfstate got broken by this bug, so I think it should have higher priority.

@breathingdust breathingdust added the bug Addresses a defect in current functionality. label Sep 22, 2021
@zhelding
Copy link
Contributor

Pull request #21306 has significantly refactored the AWS Provider codebase. As a result, most PRs opened prior to the refactor now have merge conflicts that must be resolved before proceeding.

Specifically, PR #21306 relocated the code for all AWS resources and data sources from a single aws directory to a large number of separate directories in internal/service, each corresponding to a particular AWS service. This separation of code has also allowed for us to simplify the names of underlying functions -- while still avoiding namespace collisions.

We recognize that many pull requests have been open for some time without yet being addressed by our maintainers. Therefore, we want to make it clear that resolving these conflicts in no way affects the prioritization of a particular pull request. Once a pull request has been prioritized for review, the necessary changes will be made by a maintainer -- either directly or in collaboration with the pull request author.

For a more complete description of this refactor, including examples of how old filepaths and function names correspond to their new counterparts: please refer to issue #20000.

For a quick guide on how to amend your pull request to resolve the merge conflicts resulting from this refactor and bring it in line with our new code patterns: please refer to our Service Package Refactor Pull Request Guide.

@kyontan kyontan changed the title [CRITICAL] Fix default value in cloudfront_distribution's origin.origin_path Fix missing default value in cloudfront_distribution's origin.origin_path Oct 19, 2021
@kyontan
Copy link
Contributor Author

kyontan commented Oct 19, 2021

I have followed the refactoring, and waiting for maintainer review.

@YakDriver YakDriver self-assigned this Mar 25, 2022
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

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

Thank you 🎉

% make testacc TESTS=TestAccCloudFrontDistribution PKG=cloudfront
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudfront/... -v -count 1 -parallel 20 -run='TestAccCloudFrontDistribution'  -timeout 180m
--- PASS: TestAccCloudFrontDistribution_OrderedCacheBehaviorForwardedValues_headers (202.36s)
--- PASS: TestAccCloudFrontDistribution_DefaultCacheBehaviorForwardedValuesCookies_whitelistedNames (204.63s)
--- PASS: TestAccCloudFrontDistribution_DefaultCacheBehavior_trustedSigners (204.70s)
--- PASS: TestAccCloudFrontDistribution_OrderedCacheBehaviorForwardedValuesCookies_whitelistedNames (204.97s)
--- PASS: TestAccCloudFrontDistribution_ViewerCertificate_acmCertificateARN (224.22s)
--- PASS: TestAccCloudFrontDistribution_DefaultCacheBehavior_trustedKeyGroups (232.73s)
--- PASS: TestAccCloudFrontDistribution_DefaultCacheBehavior_realtimeLogARN (239.07s)
--- PASS: TestAccCloudFrontDistribution_OrderedCacheBehavior_realtimeLogARN (248.34s)
--- PASS: TestAccCloudFrontDistribution_DefaultCacheBehaviorForwardedValues_headers (256.20s)
--- PASS: TestAccCloudFrontDistribution_ViewerCertificateACMCertificateARN_conflictsWithCloudFrontDefaultCertificate (268.27s)
--- PASS: TestAccCloudFrontDistribution_http11 (370.16s)
--- PASS: TestAccCloudFrontDistribution_isIPV6Enabled (371.68s)
--- PASS: TestAccCloudFrontDistribution_Origin_emptyDomainName (0.80s)
--- PASS: TestAccCloudFrontDistribution_Origin_emptyOriginID (0.78s)
--- PASS: TestAccCloudFrontDistribution_noCustomErrorResponse (384.29s)
--- PASS: TestAccCloudFrontDistribution_Origin_connectionAttempts (386.37s)
--- PASS: TestAccCloudFrontDistributionDataSource_basic (387.11s)
--- PASS: TestAccCloudFrontDistribution_retainOnDelete (389.10s)
--- PASS: TestAccCloudFrontDistribution_waitForDeployment (396.73s)
--- PASS: TestAccCloudFrontDistribution_orderedCacheBehaviorCachePolicy (487.60s)
--- PASS: TestAccCloudFrontDistribution_originGroups (497.02s)
--- PASS: TestAccCloudFrontDistribution_disappears (189.06s)
--- PASS: TestAccCloudFrontDistribution_enabled (560.13s)
--- PASS: TestAccCloudFrontDistribution_orderedCacheBehavior (355.57s)
--- PASS: TestAccCloudFrontDistribution_originPolicyOrdered (359.08s)
--- PASS: TestAccCloudFrontDistribution_noOptionalItems (337.64s)
--- PASS: TestAccCloudFrontDistribution_multiOrigin (366.12s)
--- PASS: TestAccCloudFrontDistribution_originPolicyDefault (372.31s)
--- PASS: TestAccCloudFrontDistribution_customOrigin (332.03s)
--- PASS: TestAccCloudFrontDistribution_Origin_originShield (450.51s)
--- PASS: TestAccCloudFrontDistribution_s3Origin (421.80s)
--- PASS: TestAccCloudFrontDistribution_Origin_connectionTimeout (414.74s)
--- PASS: TestAccCloudFrontDistribution_orderedCacheBehaviorResponseHeadersPolicy (358.96s)
--- PASS: TestAccCloudFrontDistribution_s3OriginWithTags (514.25s)
--- PASS: TestAccCloudFrontDistribution_forwardedValuesToCachePolicy (511.07s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/cloudfront	886.647s

@YakDriver YakDriver merged commit ca20eb9 into hashicorp:main Mar 25, 2022
@github-actions github-actions bot added this to the v4.8.0 milestone Mar 25, 2022
@github-actions
Copy link

This functionality has been released in v4.8.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. Thank you!

@github-actions
Copy link

github-actions bot commented May 5, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2022
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/cloudfront Issues and PRs that pertain to the cloudfront service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants