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 resource aws_sqs_queue_redrive_policy #26733

Merged
merged 15 commits into from
Sep 13, 2022

Conversation

mlund01
Copy link
Contributor

@mlund01 mlund01 commented Sep 9, 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

Closes #22577

This PR adds the resource aws_sqs_queue_redrive_policy, which allows you to create a redrive policy after an existing sqs queue. Read more in #22577 on why this is needed.

The internals of this resource are nearly identical to the aws_sqs_queue_policy resource, with a few small exceptions. For this reason, I created a function generator that the CRUD functions utilize, reusing most of the function definitions from the aws_sqs_queue_policy CRUD methods, with a few exceptions. The function generators are in attribute_funcs file within the sqs package. For this reason, I have also listed the output of the aws_sqs_queue_policy resource tests below.

Additional note, by creating this as a shared function and using the latest context-based methods, this also updates the aws_sqs_queue_policy resource to use the context CRUD methods.

Output from acceptance testing:

$ make testacc TESTS=TestAccSQSQueueRedrivePolicy_ PKG=sqs

=== RUN   TestAccSQSQueueRedrivePolicy_basic
=== PAUSE TestAccSQSQueueRedrivePolicy_basic
=== RUN   TestAccSQSQueueRedrivePolicy_disappears
=== PAUSE TestAccSQSQueueRedrivePolicy_disappears
=== RUN   TestAccSQSQueueRedrivePolicy_Disappears_queue
=== PAUSE TestAccSQSQueueRedrivePolicy_Disappears_queue
=== RUN   TestAccSQSQueueRedrivePolicy_update
=== PAUSE TestAccSQSQueueRedrivePolicy_update
=== CONT  TestAccSQSQueueRedrivePolicy_basic
=== CONT  TestAccSQSQueueRedrivePolicy_Disappears_queue
=== CONT  TestAccSQSQueueRedrivePolicy_disappears
=== CONT  TestAccSQSQueueRedrivePolicy_update
--- PASS: TestAccSQSQueueRedrivePolicy_basic (132.95s)
--- PASS: TestAccSQSQueueRedrivePolicy_Disappears_queue (136.76s)
--- PASS: TestAccSQSQueueRedrivePolicy_disappears (142.35s)
--- PASS: TestAccSQSQueueRedrivePolicy_update (161.13s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sqs	163.709s
...
$ make testacc TESTS=TestAccSQSQueuePolicy_ PKG=sqs

=== RUN   TestAccSQSQueuePolicy_basic
=== PAUSE TestAccSQSQueuePolicy_basic
=== RUN   TestAccSQSQueuePolicy_disappears
=== PAUSE TestAccSQSQueuePolicy_disappears
=== RUN   TestAccSQSQueuePolicy_Disappears_queue
=== PAUSE TestAccSQSQueuePolicy_Disappears_queue
=== RUN   TestAccSQSQueuePolicy_update
=== PAUSE TestAccSQSQueuePolicy_update
=== CONT  TestAccSQSQueuePolicy_basic
=== CONT  TestAccSQSQueuePolicy_Disappears_queue
=== CONT  TestAccSQSQueuePolicy_update
=== CONT  TestAccSQSQueuePolicy_disappears
--- PASS: TestAccSQSQueuePolicy_basic (103.59s)
--- PASS: TestAccSQSQueuePolicy_Disappears_queue (105.82s)
--- PASS: TestAccSQSQueuePolicy_disappears (113.81s)
--- PASS: TestAccSQSQueuePolicy_update (132.84s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sqs	135.581s
...

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/acm Issues and PRs that pertain to the acm service. service/sqs Issues and PRs that pertain to the sqs service. sweeper Pertains to changes to or issues with the sweeper. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. labels Sep 9, 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 @mlund01 👋

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 CONTRIBUTOR 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! 😃

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Sep 9, 2022
@ewbankkit ewbankkit assigned ewbankkit and unassigned ewbankkit Sep 9, 2022
@ewbankkit ewbankkit added new-resource Introduces a new resource. and removed service/acm Issues and PRs that pertain to the acm service. labels Sep 13, 2022
@github-actions github-actions bot removed the sweeper Pertains to changes to or issues with the sweeper. label Sep 13, 2022
Copy link
Contributor Author

@mlund01 mlund01 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for taking the time to review and update @ewbankkit

… yaml: line 7: could not find expected ':'".
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=TestAccSQSQueuePolicy_' PKG=sqs ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/sqs/... -v -count 1 -parallel 2  -run=TestAccSQSQueuePolicy_ -timeout 180m
=== RUN   TestAccSQSQueuePolicy_basic
=== PAUSE TestAccSQSQueuePolicy_basic
=== RUN   TestAccSQSQueuePolicy_disappears
=== PAUSE TestAccSQSQueuePolicy_disappears
=== RUN   TestAccSQSQueuePolicy_Disappears_queue
=== PAUSE TestAccSQSQueuePolicy_Disappears_queue
=== RUN   TestAccSQSQueuePolicy_update
=== PAUSE TestAccSQSQueuePolicy_update
=== CONT  TestAccSQSQueuePolicy_basic
=== CONT  TestAccSQSQueuePolicy_Disappears_queue
--- PASS: TestAccSQSQueuePolicy_basic (108.21s)
=== CONT  TestAccSQSQueuePolicy_update
--- PASS: TestAccSQSQueuePolicy_Disappears_queue (108.84s)
=== CONT  TestAccSQSQueuePolicy_disappears
--- PASS: TestAccSQSQueuePolicy_disappears (114.13s)
--- PASS: TestAccSQSQueuePolicy_update (135.74s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sqs	247.922s
% make testacc TESTARGS='-run=TestAccSQSQueueRedrivePolicy_' PKG=sqs ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/sqs/... -v -count 1 -parallel 2  -run=TestAccSQSQueueRedrivePolicy_ -timeout 180m
=== RUN   TestAccSQSQueueRedrivePolicy_basic
=== PAUSE TestAccSQSQueueRedrivePolicy_basic
=== RUN   TestAccSQSQueueRedrivePolicy_disappears
=== PAUSE TestAccSQSQueueRedrivePolicy_disappears
=== RUN   TestAccSQSQueueRedrivePolicy_Disappears_queue
=== PAUSE TestAccSQSQueueRedrivePolicy_Disappears_queue
=== RUN   TestAccSQSQueueRedrivePolicy_update
=== PAUSE TestAccSQSQueueRedrivePolicy_update
=== CONT  TestAccSQSQueueRedrivePolicy_basic
=== CONT  TestAccSQSQueueRedrivePolicy_Disappears_queue
--- PASS: TestAccSQSQueueRedrivePolicy_basic (136.50s)
=== CONT  TestAccSQSQueueRedrivePolicy_update
--- PASS: TestAccSQSQueueRedrivePolicy_Disappears_queue (139.63s)
=== CONT  TestAccSQSQueueRedrivePolicy_disappears
--- PASS: TestAccSQSQueueRedrivePolicy_disappears (144.67s)
--- PASS: TestAccSQSQueueRedrivePolicy_update (164.81s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sqs	305.182s
% make testacc TESTARGS='-run=TestAccSQSQueueRedriveAllowPolicy_' PKG=sqs ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/sqs/... -v -count 1 -parallel 2  -run=TestAccSQSQueueRedriveAllowPolicy_ -timeout 180m
=== RUN   TestAccSQSQueueRedriveAllowPolicy_basic
=== PAUSE TestAccSQSQueueRedriveAllowPolicy_basic
=== RUN   TestAccSQSQueueRedriveAllowPolicy_disappears
=== PAUSE TestAccSQSQueueRedriveAllowPolicy_disappears
=== RUN   TestAccSQSQueueRedriveAllowPolicy_Disappears_queue
=== PAUSE TestAccSQSQueueRedriveAllowPolicy_Disappears_queue
=== RUN   TestAccSQSQueueRedriveAllowPolicy_update
=== PAUSE TestAccSQSQueueRedriveAllowPolicy_update
=== CONT  TestAccSQSQueueRedriveAllowPolicy_basic
=== CONT  TestAccSQSQueueRedriveAllowPolicy_Disappears_queue
--- PASS: TestAccSQSQueueRedriveAllowPolicy_basic (138.23s)
=== CONT  TestAccSQSQueueRedriveAllowPolicy_disappears
--- PASS: TestAccSQSQueueRedriveAllowPolicy_Disappears_queue (138.92s)
=== CONT  TestAccSQSQueueRedriveAllowPolicy_update
--- PASS: TestAccSQSQueueRedriveAllowPolicy_disappears (144.32s)
--- PASS: TestAccSQSQueueRedriveAllowPolicy_update (162.29s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sqs	305.148s
% make testacc TESTARGS='-run=TestAccSQSQueueDataSource_\|TestAccSQSQueue_' PKG=sqs ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/sqs/... -v -count 1 -parallel 2  -run=TestAccSQSQueueDataSource_\|TestAccSQSQueue_ -timeout 180m
=== RUN   TestAccSQSQueueDataSource_basic
=== PAUSE TestAccSQSQueueDataSource_basic
=== RUN   TestAccSQSQueueDataSource_tags
=== PAUSE TestAccSQSQueueDataSource_tags
=== RUN   TestAccSQSQueue_basic
=== PAUSE TestAccSQSQueue_basic
=== RUN   TestAccSQSQueue_disappears
=== PAUSE TestAccSQSQueue_disappears
=== RUN   TestAccSQSQueue_Name_generated
=== PAUSE TestAccSQSQueue_Name_generated
=== RUN   TestAccSQSQueue_NameGenerated_fifoQueue
=== PAUSE TestAccSQSQueue_NameGenerated_fifoQueue
=== RUN   TestAccSQSQueue_namePrefix
=== PAUSE TestAccSQSQueue_namePrefix
=== RUN   TestAccSQSQueue_NamePrefix_fifoQueue
=== PAUSE TestAccSQSQueue_NamePrefix_fifoQueue
=== RUN   TestAccSQSQueue_tags
=== PAUSE TestAccSQSQueue_tags
=== RUN   TestAccSQSQueue_update
=== PAUSE TestAccSQSQueue_update
=== RUN   TestAccSQSQueue_Policy_basic
=== PAUSE TestAccSQSQueue_Policy_basic
=== RUN   TestAccSQSQueue_Policy_ignoreEquivalent
=== PAUSE TestAccSQSQueue_Policy_ignoreEquivalent
=== RUN   TestAccSQSQueue_recentlyDeleted
=== PAUSE TestAccSQSQueue_recentlyDeleted
=== RUN   TestAccSQSQueue_redrivePolicy
=== PAUSE TestAccSQSQueue_redrivePolicy
=== RUN   TestAccSQSQueue_redriveAllowPolicy
=== PAUSE TestAccSQSQueue_redriveAllowPolicy
=== RUN   TestAccSQSQueue_fifoQueue
=== PAUSE TestAccSQSQueue_fifoQueue
=== RUN   TestAccSQSQueue_FIFOQueue_expectNameError
=== PAUSE TestAccSQSQueue_FIFOQueue_expectNameError
=== RUN   TestAccSQSQueue_FIFOQueue_contentBasedDeduplication
=== PAUSE TestAccSQSQueue_FIFOQueue_contentBasedDeduplication
=== RUN   TestAccSQSQueue_FIFOQueue_highThroughputMode
=== PAUSE TestAccSQSQueue_FIFOQueue_highThroughputMode
=== RUN   TestAccSQSQueue_StandardQueue_expectContentBasedDeduplicationError
=== PAUSE TestAccSQSQueue_StandardQueue_expectContentBasedDeduplicationError
=== RUN   TestAccSQSQueue_encryption
=== PAUSE TestAccSQSQueue_encryption
=== RUN   TestAccSQSQueue_zeroVisibilityTimeoutSeconds
=== PAUSE TestAccSQSQueue_zeroVisibilityTimeoutSeconds
=== RUN   TestAccSQSQueue_defaultKMSDataKeyReusePeriodSeconds
=== PAUSE TestAccSQSQueue_defaultKMSDataKeyReusePeriodSeconds
=== CONT  TestAccSQSQueueDataSource_basic
=== CONT  TestAccSQSQueue_recentlyDeleted
--- PASS: TestAccSQSQueueDataSource_basic (45.48s)
=== CONT  TestAccSQSQueue_namePrefix
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-prefix-20220913133558004500000004 still exists
--- FAIL: TestAccSQSQueue_namePrefix (45.45s)
=== CONT  TestAccSQSQueue_Policy_ignoreEquivalent
=== CONT  TestAccSQSQueue_recentlyDeleted
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-5291812223422315905 still exists
--- FAIL: TestAccSQSQueue_recentlyDeleted (141.20s)
=== CONT  TestAccSQSQueue_Policy_basic
--- PASS: TestAccSQSQueue_Policy_ignoreEquivalent (101.21s)
=== CONT  TestAccSQSQueue_update
--- PASS: TestAccSQSQueue_Policy_basic (94.89s)
=== CONT  TestAccSQSQueue_tags
--- PASS: TestAccSQSQueue_update (83.72s)
=== CONT  TestAccSQSQueue_NamePrefix_fifoQueue
=== CONT  TestAccSQSQueue_tags
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-1897314527937579916 still exists
--- FAIL: TestAccSQSQueue_tags (67.99s)
=== CONT  TestAccSQSQueue_FIFOQueue_highThroughputMode
=== CONT  TestAccSQSQueue_NamePrefix_fifoQueue
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-prefix-20220913133948402900000008.fifo still exists
--- FAIL: TestAccSQSQueue_NamePrefix_fifoQueue (46.25s)
=== CONT  TestAccSQSQueue_defaultKMSDataKeyReusePeriodSeconds
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-8278462624834602555 still exists
--- FAIL: TestAccSQSQueue_defaultKMSDataKeyReusePeriodSeconds (44.94s)
=== CONT  TestAccSQSQueue_zeroVisibilityTimeoutSeconds
=== CONT  TestAccSQSQueue_FIFOQueue_highThroughputMode
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-4983630808639157017.fifo still exists
--- FAIL: TestAccSQSQueue_FIFOQueue_highThroughputMode (83.31s)
=== CONT  TestAccSQSQueue_encryption
=== CONT  TestAccSQSQueue_zeroVisibilityTimeoutSeconds
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-3294804985754665186 still exists
--- FAIL: TestAccSQSQueue_zeroVisibilityTimeoutSeconds (44.84s)
=== CONT  TestAccSQSQueue_StandardQueue_expectContentBasedDeduplicationError
--- PASS: TestAccSQSQueue_StandardQueue_expectContentBasedDeduplicationError (2.01s)
=== CONT  TestAccSQSQueue_disappears
--- PASS: TestAccSQSQueue_disappears (59.88s)
=== CONT  TestAccSQSQueue_NameGenerated_fifoQueue
=== CONT  TestAccSQSQueue_encryption
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-8686378499255522412 still exists
--- FAIL: TestAccSQSQueue_encryption (120.21s)
=== CONT  TestAccSQSQueue_Name_generated
--- PASS: TestAccSQSQueue_NameGenerated_fifoQueue (44.70s)
=== CONT  TestAccSQSQueue_fifoQueue
=== CONT  TestAccSQSQueue_Name_generated
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/terraform-20220913134340041300000010 still exists
--- FAIL: TestAccSQSQueue_Name_generated (44.98s)
=== CONT  TestAccSQSQueue_FIFOQueue_contentBasedDeduplication
=== CONT  TestAccSQSQueue_fifoQueue
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-547316892527749503.fifo still exists
--- FAIL: TestAccSQSQueue_fifoQueue (46.14s)
=== CONT  TestAccSQSQueue_FIFOQueue_expectNameError
--- PASS: TestAccSQSQueue_FIFOQueue_expectNameError (1.95s)
=== CONT  TestAccSQSQueue_basic
=== CONT  TestAccSQSQueue_FIFOQueue_contentBasedDeduplication
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-4229132132419062898.fifo still exists
--- FAIL: TestAccSQSQueue_FIFOQueue_contentBasedDeduplication (45.33s)
=== CONT  TestAccSQSQueueDataSource_tags
=== CONT  TestAccSQSQueue_basic
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-4076105577281736534 still exists
--- FAIL: TestAccSQSQueue_basic (44.68s)
=== CONT  TestAccSQSQueue_redriveAllowPolicy
--- PASS: TestAccSQSQueueDataSource_tags (43.75s)
=== CONT  TestAccSQSQueue_redrivePolicy
=== CONT  TestAccSQSQueue_redriveAllowPolicy
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-802405050527071055-1 still exists
--- FAIL: TestAccSQSQueue_redriveAllowPolicy (75.73s)
=== CONT  TestAccSQSQueue_redrivePolicy
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: SQS Queue https://sqs.us-west-2.amazonaws.com/123456789012/tf-acc-test-270655400837734910-1 still exists
--- FAIL: TestAccSQSQueue_redrivePolicy (74.18s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/sqs	719.759s
FAIL
make: *** [testacc] Error 1

The failures are unrelated are this changes and occur in CI; something to do with eventual consistency.

@ewbankkit
Copy link
Contributor

@mlund01 Thanks for the contribution 🎉 👏.
I added aws_sqs_queue_redrive_allow_policy which was very easy to do after your refactoring.

@ewbankkit ewbankkit merged commit d24492d into hashicorp:main Sep 13, 2022
@github-actions github-actions bot added this to the v4.31.0 milestone Sep 13, 2022
@github-actions
Copy link

This functionality has been released in v4.31.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 Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/sqs Issues and PRs that pertain to the sqs 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.

Cannot use SQS redrive_allow_policy correctly without creating a cycle
2 participants