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 race condition in SNS topic and topic policy resources #29226

Merged
merged 7 commits into from
Feb 6, 2023

Conversation

gdavison
Copy link
Contributor

@gdavison gdavison commented Feb 3, 2023

The policy attribute in the aws_sns_topic and aws_sns_topic_policy resources can sometimes return the unique ID instead of the corresponding ARN for AWS principals. This can be resolved by retrying until valid values are returned.

References

Output from Acceptance Testing

$ make testacc PKG=sns TESTS='TestAccSNSTopic_|TestAccSNSTopicPolicy_'

--- PASS: TestAccSNSTopic_fifoExpectContentBasedDeduplicationError (7.94s)
--- PASS: TestAccSNSTopicPolicy_Disappears_topic (34.70s)
--- PASS: TestAccSNSTopic_disappears (34.94s)
--- PASS: TestAccSNSTopicPolicy_disappears (40.08s)
--- PASS: TestAccSNSTopic_basic (50.97s)
--- PASS: TestAccSNSTopic_namePrefix (50.97s)
--- PASS: TestAccSNSTopic_withDeliveryPolicy (51.03s)
--- PASS: TestAccSNSTopic_NameGenerated_fifoTopic (52.43s)
--- PASS: TestAccSNSTopic_policy (53.04s)
--- PASS: TestAccSNSTopic_NamePrefix_fifoTopic (53.08s)
--- PASS: TestAccSNSTopicPolicy_basic (53.09s)
--- PASS: TestAccSNSTopic_Name_fifoTopic (56.29s)
--- PASS: TestAccSNSTopic_name (55.99s)
--- PASS: TestAccSNSTopicPolicy_ignoreEquivalent (69.61s)
--- PASS: TestAccSNSTopic_deliveryStatus (73.02s)
--- PASS: TestAccSNSTopic_withIAMRole (73.87s)
--- PASS: TestAccSNSTopicPolicy_updated (79.48s)
--- PASS: TestAccSNSTopic_encryption (79.60s)
--- PASS: TestAccSNSTopic_fifoWithContentBasedDeduplication (79.68s)
--- PASS: TestAccSNSTopic_tags (97.47s)
--- PASS: TestAccSNSTopic_withFakeIAMRole (140.48s)

@github-actions
Copy link

github-actions bot commented Feb 3, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added service/sns Issues and PRs that pertain to the sns service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/sns Issues and PRs that pertain to the sns service. labels Feb 3, 2023
@github-actions github-actions bot added service/sns Issues and PRs that pertain to the sns service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 3, 2023
@github-actions github-actions bot added the service/iam Issues and PRs that pertain to the iam service. label Feb 3, 2023
@github-actions github-actions bot added github_actions Pull requests that update Github_actions code linter Pertains to changes to or issues with the various linters. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. labels Feb 3, 2023
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 TESTARGS='-run=TestAccIAMGroupPolicyAttachment_\|TestAccIAMRolePolicyAttachment_\|TestAccIAMUserPolicyAttachment_' PKG=iam ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/iam/... -v -count 1 -parallel 3  -run=TestAccIAMGroupPolicyAttachment_\|TestAccIAMRolePolicyAttachment_\|TestAccIAMUserPolicyAttachment_ -timeout 180m
=== RUN   TestAccIAMGroupPolicyAttachment_basic
=== PAUSE TestAccIAMGroupPolicyAttachment_basic
=== RUN   TestAccIAMRolePolicyAttachment_basic
=== PAUSE TestAccIAMRolePolicyAttachment_basic
=== RUN   TestAccIAMRolePolicyAttachment_disappears
=== PAUSE TestAccIAMRolePolicyAttachment_disappears
=== RUN   TestAccIAMRolePolicyAttachment_Disappears_role
=== PAUSE TestAccIAMRolePolicyAttachment_Disappears_role
=== RUN   TestAccIAMUserPolicyAttachment_basic
=== PAUSE TestAccIAMUserPolicyAttachment_basic
=== CONT  TestAccIAMGroupPolicyAttachment_basic
=== CONT  TestAccIAMRolePolicyAttachment_Disappears_role
=== CONT  TestAccIAMUserPolicyAttachment_basic
--- PASS: TestAccIAMRolePolicyAttachment_Disappears_role (14.94s)
=== CONT  TestAccIAMRolePolicyAttachment_disappears
--- PASS: TestAccIAMRolePolicyAttachment_disappears (14.22s)
=== CONT  TestAccIAMRolePolicyAttachment_basic
--- PASS: TestAccIAMUserPolicyAttachment_basic (33.67s)
--- PASS: TestAccIAMGroupPolicyAttachment_basic (33.81s)
--- PASS: TestAccIAMRolePolicyAttachment_basic (26.82s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/iam	61.149s
% make testacc TESTARGS='-run=TestAccSNSTopic_\|TestAccSNSTopicPolicy_' PKG=sns ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/sns/... -v -count 1 -parallel 3  -run=TestAccSNSTopic_\|TestAccSNSTopicPolicy_ -timeout 180m
=== RUN   TestAccSNSTopicPolicy_basic
=== PAUSE TestAccSNSTopicPolicy_basic
=== RUN   TestAccSNSTopicPolicy_updated
=== PAUSE TestAccSNSTopicPolicy_updated
=== RUN   TestAccSNSTopicPolicy_Disappears_topic
=== PAUSE TestAccSNSTopicPolicy_Disappears_topic
=== RUN   TestAccSNSTopicPolicy_disappears
=== PAUSE TestAccSNSTopicPolicy_disappears
=== RUN   TestAccSNSTopicPolicy_ignoreEquivalent
=== PAUSE TestAccSNSTopicPolicy_ignoreEquivalent
=== RUN   TestAccSNSTopic_basic
=== PAUSE TestAccSNSTopic_basic
=== RUN   TestAccSNSTopic_disappears
=== PAUSE TestAccSNSTopic_disappears
=== RUN   TestAccSNSTopic_name
=== PAUSE TestAccSNSTopic_name
=== RUN   TestAccSNSTopic_namePrefix
=== PAUSE TestAccSNSTopic_namePrefix
=== RUN   TestAccSNSTopic_tags
=== PAUSE TestAccSNSTopic_tags
=== RUN   TestAccSNSTopic_policy
=== PAUSE TestAccSNSTopic_policy
=== RUN   TestAccSNSTopic_withIAMRole
=== PAUSE TestAccSNSTopic_withIAMRole
=== RUN   TestAccSNSTopic_withFakeIAMRole
=== PAUSE TestAccSNSTopic_withFakeIAMRole
=== RUN   TestAccSNSTopic_withDeliveryPolicy
=== PAUSE TestAccSNSTopic_withDeliveryPolicy
=== RUN   TestAccSNSTopic_deliveryStatus
=== PAUSE TestAccSNSTopic_deliveryStatus
=== RUN   TestAccSNSTopic_NameGenerated_fifoTopic
=== PAUSE TestAccSNSTopic_NameGenerated_fifoTopic
=== RUN   TestAccSNSTopic_Name_fifoTopic
=== PAUSE TestAccSNSTopic_Name_fifoTopic
=== RUN   TestAccSNSTopic_NamePrefix_fifoTopic
=== PAUSE TestAccSNSTopic_NamePrefix_fifoTopic
=== RUN   TestAccSNSTopic_fifoWithContentBasedDeduplication
=== PAUSE TestAccSNSTopic_fifoWithContentBasedDeduplication
=== RUN   TestAccSNSTopic_fifoExpectContentBasedDeduplicationError
=== PAUSE TestAccSNSTopic_fifoExpectContentBasedDeduplicationError
=== RUN   TestAccSNSTopic_encryption
=== PAUSE TestAccSNSTopic_encryption
=== CONT  TestAccSNSTopicPolicy_basic
=== CONT  TestAccSNSTopic_withIAMRole
=== CONT  TestAccSNSTopic_Name_fifoTopic
--- PASS: TestAccSNSTopic_Name_fifoTopic (18.54s)
=== CONT  TestAccSNSTopic_fifoExpectContentBasedDeduplicationError
--- PASS: TestAccSNSTopicPolicy_basic (20.04s)
=== CONT  TestAccSNSTopic_encryption
=== CONT  TestAccSNSTopic_fifoWithContentBasedDeduplication
--- PASS: TestAccSNSTopic_fifoExpectContentBasedDeduplicationError (2.00s)
--- PASS: TestAccSNSTopic_withIAMRole (27.50s)
=== CONT  TestAccSNSTopic_deliveryStatus
--- PASS: TestAccSNSTopic_encryption (29.98s)
=== CONT  TestAccSNSTopic_NameGenerated_fifoTopic
--- PASS: TestAccSNSTopic_fifoWithContentBasedDeduplication (30.57s)
=== CONT  TestAccSNSTopic_NamePrefix_fifoTopic
--- PASS: TestAccSNSTopic_deliveryStatus (29.52s)
=== CONT  TestAccSNSTopic_disappears
--- PASS: TestAccSNSTopic_NameGenerated_fifoTopic (18.28s)
=== CONT  TestAccSNSTopic_policy
--- PASS: TestAccSNSTopic_NamePrefix_fifoTopic (18.32s)
=== CONT  TestAccSNSTopic_tags
--- PASS: TestAccSNSTopic_disappears (13.72s)
=== CONT  TestAccSNSTopic_namePrefix
--- PASS: TestAccSNSTopic_policy (20.37s)
=== CONT  TestAccSNSTopic_name
--- PASS: TestAccSNSTopic_namePrefix (18.21s)
=== CONT  TestAccSNSTopic_withDeliveryPolicy
--- PASS: TestAccSNSTopic_name (17.65s)
=== CONT  TestAccSNSTopicPolicy_disappears
--- PASS: TestAccSNSTopic_withDeliveryPolicy (17.94s)
=== CONT  TestAccSNSTopic_basic
--- PASS: TestAccSNSTopic_tags (43.30s)
=== CONT  TestAccSNSTopicPolicy_ignoreEquivalent
--- PASS: TestAccSNSTopicPolicy_disappears (18.48s)
=== CONT  TestAccSNSTopicPolicy_Disappears_topic
--- PASS: TestAccSNSTopic_basic (21.26s)
=== CONT  TestAccSNSTopic_withFakeIAMRole
--- PASS: TestAccSNSTopicPolicy_ignoreEquivalent (24.54s)
=== CONT  TestAccSNSTopicPolicy_updated
--- PASS: TestAccSNSTopicPolicy_Disappears_topic (13.94s)
--- PASS: TestAccSNSTopicPolicy_updated (27.84s)
--- PASS: TestAccSNSTopic_withFakeIAMRole (128.79s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sns	262.473s

@gdavison gdavison merged commit 20bc8d9 into main Feb 6, 2023
@gdavison gdavison deleted the b-sns-policy-principal-race branch February 6, 2023 18:51
@github-actions github-actions bot removed linter Pertains to changes to or issues with the various linters. service/iam Issues and PRs that pertain to the iam service. github_actions Pull requests that update Github_actions code repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. labels Feb 6, 2023
@github-actions github-actions bot added this to the v4.54.0 milestone Feb 6, 2023
github-actions bot pushed a commit that referenced this pull request Feb 6, 2023
@github-actions
Copy link

github-actions bot commented Feb 9, 2023

This functionality has been released in v4.54.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 Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/sns Issues and PRs that pertain to the sns service. size/XL 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