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

Add retry on MalformedPolicyDocumentException to wait for IAM propagation on KMS policy update #24697

Conversation

neinkeinkaffee
Copy link
Contributor

@neinkeinkaffee neinkeinkaffee commented May 8, 2022

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

Relates OR Closes #24696

This PR proposes to retry KMS policy updates when a MalformedPolicyDocumentException occurs. The intention is to avoid failing when a KMS policy reference IAM resources that get created at the same time.

Output from acceptance testing:

$ make testacc TESTS=TestAccKMSKey_Policy PKG=kms
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/kms/... -v -count 1 -parallel 20 -run='TestAccKMSKey_Policy'  -timeout 180m
--- PASS: TestAccKMSKey_Policy_booleanCondition (68.99s)
--- PASS: TestAccKMSKey_Policy_iamRole (92.13s)
--- PASS: TestAccKMSKey_Policy_bypassUpdate (111.73s)
--- PASS: TestAccKMSKey_Policy_iamServiceLinkedRole (111.79s)
--- PASS: TestAccKMSKey_Policy_basic (120.11s)
--- PASS: TestAccKMSKey_Policy_iamRoleUpdate (125.12s)
--- PASS: TestAccKMSKey_Policy_iamRoleOrder (160.30s)
--- PASS: TestAccKMSKey_Policy_bypass (209.87s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/kms        212.464s

@github-actions github-actions bot added service/kms Issues and PRs that pertain to the kms 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 needs-triage Waiting for first response or review from a maintainer. labels May 8, 2022
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 @neinkeinkaffee 👋

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 size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/XS Managed by automation to categorize the size of a PR. labels May 8, 2022
@github-actions github-actions bot added size/XS Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels May 8, 2022
@neinkeinkaffee neinkeinkaffee changed the title [WIP] Add retry on MalformedPolicyDocumentException to wait for IAM propagation on KMS policy update Add retry on MalformedPolicyDocumentException to wait for IAM propagation on KMS policy update May 8, 2022
@ewbankkit ewbankkit added the bug Addresses a defect in current functionality. label May 9, 2022
@github-actions github-actions bot added size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels May 9, 2022
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTS=TestAccKMSKey_Policy PKG=kms
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/kms/... -v -count 1 -parallel 20 -run='TestAccKMSKey_Policy'  -timeout 180m
=== RUN   TestAccKMSKey_Policy_basic
=== PAUSE TestAccKMSKey_Policy_basic
=== RUN   TestAccKMSKey_Policy_bypass
=== PAUSE TestAccKMSKey_Policy_bypass
=== RUN   TestAccKMSKey_Policy_bypassUpdate
=== PAUSE TestAccKMSKey_Policy_bypassUpdate
=== RUN   TestAccKMSKey_Policy_iamRole
=== PAUSE TestAccKMSKey_Policy_iamRole
=== RUN   TestAccKMSKey_Policy_iamRoleUpdate
=== PAUSE TestAccKMSKey_Policy_iamRoleUpdate
=== RUN   TestAccKMSKey_Policy_iamRoleOrder
=== PAUSE TestAccKMSKey_Policy_iamRoleOrder
=== RUN   TestAccKMSKey_Policy_iamServiceLinkedRole
=== PAUSE TestAccKMSKey_Policy_iamServiceLinkedRole
=== RUN   TestAccKMSKey_Policy_booleanCondition
=== PAUSE TestAccKMSKey_Policy_booleanCondition
=== CONT  TestAccKMSKey_Policy_basic
=== CONT  TestAccKMSKey_Policy_iamRoleUpdate
=== CONT  TestAccKMSKey_Policy_bypass
=== CONT  TestAccKMSKey_Policy_booleanCondition
=== CONT  TestAccKMSKey_Policy_bypassUpdate
=== CONT  TestAccKMSKey_Policy_iamRoleOrder
=== CONT  TestAccKMSKey_Policy_iamRole
=== CONT  TestAccKMSKey_Policy_iamServiceLinkedRole
--- PASS: TestAccKMSKey_Policy_booleanCondition (25.38s)
--- PASS: TestAccKMSKey_Policy_basic (37.70s)
--- PASS: TestAccKMSKey_Policy_bypassUpdate (38.07s)
--- PASS: TestAccKMSKey_Policy_iamServiceLinkedRole (54.02s)
--- PASS: TestAccKMSKey_Policy_iamRoleUpdate (52.93s)
--- PASS: TestAccKMSKey_Policy_iamRole (55.41s)
--- PASS: TestAccKMSKey_Policy_iamRoleOrder (70.39s)
--- PASS: TestAccKMSKey_Policy_bypass (151.56s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/kms	155.690s

@ewbankkit
Copy link
Contributor

@neinkeinkaffee Thanks for the contribution 🎉 👏.

1 similar comment
@ewbankkit
Copy link
Contributor

@neinkeinkaffee Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit b8ff9d9 into hashicorp:main May 9, 2022
@github-actions github-actions bot added this to the v4.14.0 milestone May 9, 2022
@github-actions
Copy link

This functionality has been released in v4.14.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

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 Jun 14, 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/kms Issues and PRs that pertain to the kms 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.

Allow time for propagation of new IAM resources on KMS policy update
2 participants