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_secretsmanager_secret_rotation: Fix bug with updates #35024

Merged
merged 3 commits into from
Dec 21, 2023

Conversation

gdavison
Copy link
Contributor

Description

Due to a DiffSuppressFunc, changes to rotation_rules.automatically_after_days were incorrectly ignored if rotation_rules.schedule_expression was set.

Also adds required ClientRequestToken for idempotent requests.

Output from Acceptance Testing

% make testacc PKG=secretsmanager TESTS=TestAccSecretsManagerSecretRotation_

--- PASS: TestAccSecretsManagerSecretRotation_basic (41.36s)
--- PASS: TestAccSecretsManagerSecretRotation_scheduleExpressionToDays (52.99s)
--- PASS: TestAccSecretsManagerSecretRotation_scheduleExpression (54.47s)
--- PASS: TestAccSecretsManagerSecretRotation_duration (56.11s)
--- PASS: TestAccSecretsManagerSecretRotation_scheduleExpressionHours (61.52s)
% make testacc PKG=secretsmanager TESTS=TestAccSecretsManagerSecret_

--- PASS: TestAccSecretsManagerSecret_withNamePrefix (29.99s)
--- PASS: TestAccSecretsManagerSecret_basic (30.28s)
--- PASS: TestAccSecretsManagerSecret_basicReplica (38.60s)
--- PASS: TestAccSecretsManagerSecret_description (44.14s)
--- PASS: TestAccSecretsManagerSecret_RecoveryWindowInDays_recreate (44.82s)
--- PASS: TestAccSecretsManagerSecret_kmsKeyID (44.85s)
--- PASS: TestAccSecretsManagerSecret_tags (54.74s)
--- PASS: TestAccSecretsManagerSecret_policy (59.23s)
--- PASS: TestAccSecretsManagerSecret_overwriteReplica (89.74s)
% make testacc PKG=secretsmanager TESTS=TestAccSecretsManagerSecretVersion_

--- PASS: TestAccSecretsManagerSecretVersion_base64Binary (15.15s)
--- PASS: TestAccSecretsManagerSecretVersion_basicString (15.15s)
--- PASS: TestAccSecretsManagerSecretVersion_versionStages (30.67s)

Copy link

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 size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/secretsmanager Issues and PRs that pertain to the secretsmanager service. labels Dec 21, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Dec 21, 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=TestAccSecretsManagerSecretRotation_\|TestAccSecretsManagerSecret_\|TestAccSecretsManagerSecretVersion_' PKG=secretsmanager ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/secretsmanager/... -v -count 1 -parallel 2  -run=TestAccSecretsManagerSecretRotation_\|TestAccSecretsManagerSecret_\|TestAccSecretsManagerSecretVersion_ -timeout 360m
=== RUN   TestAccSecretsManagerSecretRotation_basic
=== PAUSE TestAccSecretsManagerSecretRotation_basic
=== RUN   TestAccSecretsManagerSecretRotation_scheduleExpression
=== PAUSE TestAccSecretsManagerSecretRotation_scheduleExpression
=== RUN   TestAccSecretsManagerSecretRotation_scheduleExpressionToDays
=== PAUSE TestAccSecretsManagerSecretRotation_scheduleExpressionToDays
=== RUN   TestAccSecretsManagerSecretRotation_scheduleExpressionHours
=== PAUSE TestAccSecretsManagerSecretRotation_scheduleExpressionHours
=== RUN   TestAccSecretsManagerSecretRotation_duration
=== PAUSE TestAccSecretsManagerSecretRotation_duration
=== RUN   TestAccSecretsManagerSecret_basic
=== PAUSE TestAccSecretsManagerSecret_basic
=== RUN   TestAccSecretsManagerSecret_withNamePrefix
=== PAUSE TestAccSecretsManagerSecret_withNamePrefix
=== RUN   TestAccSecretsManagerSecret_description
=== PAUSE TestAccSecretsManagerSecret_description
=== RUN   TestAccSecretsManagerSecret_basicReplica
=== PAUSE TestAccSecretsManagerSecret_basicReplica
=== RUN   TestAccSecretsManagerSecret_overwriteReplica
=== PAUSE TestAccSecretsManagerSecret_overwriteReplica
=== RUN   TestAccSecretsManagerSecret_kmsKeyID
=== PAUSE TestAccSecretsManagerSecret_kmsKeyID
=== RUN   TestAccSecretsManagerSecret_RecoveryWindowInDays_recreate
=== PAUSE TestAccSecretsManagerSecret_RecoveryWindowInDays_recreate
=== RUN   TestAccSecretsManagerSecret_tags
=== PAUSE TestAccSecretsManagerSecret_tags
=== RUN   TestAccSecretsManagerSecret_policy
=== PAUSE TestAccSecretsManagerSecret_policy
=== RUN   TestAccSecretsManagerSecretVersion_basicString
=== PAUSE TestAccSecretsManagerSecretVersion_basicString
=== RUN   TestAccSecretsManagerSecretVersion_base64Binary
=== PAUSE TestAccSecretsManagerSecretVersion_base64Binary
=== RUN   TestAccSecretsManagerSecretVersion_versionStages
=== PAUSE TestAccSecretsManagerSecretVersion_versionStages
=== CONT  TestAccSecretsManagerSecretRotation_basic
=== CONT  TestAccSecretsManagerSecret_overwriteReplica
--- PASS: TestAccSecretsManagerSecretRotation_basic (50.09s)
=== CONT  TestAccSecretsManagerSecret_policy
--- PASS: TestAccSecretsManagerSecret_overwriteReplica (84.07s)
=== CONT  TestAccSecretsManagerSecretVersion_versionStages
--- PASS: TestAccSecretsManagerSecret_policy (52.62s)
=== CONT  TestAccSecretsManagerSecretVersion_base64Binary
--- PASS: TestAccSecretsManagerSecretVersion_base64Binary (20.95s)
=== CONT  TestAccSecretsManagerSecretVersion_basicString
--- PASS: TestAccSecretsManagerSecretVersion_versionStages (45.89s)
=== CONT  TestAccSecretsManagerSecretRotation_scheduleExpressionHours
--- PASS: TestAccSecretsManagerSecretVersion_basicString (21.22s)
=== CONT  TestAccSecretsManagerSecret_basic
--- PASS: TestAccSecretsManagerSecret_basic (19.11s)
=== CONT  TestAccSecretsManagerSecretRotation_scheduleExpressionToDays
--- PASS: TestAccSecretsManagerSecretRotation_scheduleExpressionHours (61.54s)
=== CONT  TestAccSecretsManagerSecret_basicReplica
--- PASS: TestAccSecretsManagerSecret_basicReplica (23.61s)
=== CONT  TestAccSecretsManagerSecret_description
--- PASS: TestAccSecretsManagerSecretRotation_scheduleExpressionToDays (62.22s)
=== CONT  TestAccSecretsManagerSecretRotation_duration
--- PASS: TestAccSecretsManagerSecret_description (31.25s)
=== CONT  TestAccSecretsManagerSecret_RecoveryWindowInDays_recreate
--- PASS: TestAccSecretsManagerSecretRotation_duration (45.38s)
=== CONT  TestAccSecretsManagerSecret_tags
--- PASS: TestAccSecretsManagerSecret_RecoveryWindowInDays_recreate (30.81s)
=== CONT  TestAccSecretsManagerSecret_withNamePrefix
--- PASS: TestAccSecretsManagerSecret_withNamePrefix (19.00s)
=== CONT  TestAccSecretsManagerSecretRotation_scheduleExpression
--- PASS: TestAccSecretsManagerSecret_tags (41.15s)
=== CONT  TestAccSecretsManagerSecret_kmsKeyID
--- PASS: TestAccSecretsManagerSecret_kmsKeyID (32.94s)
--- PASS: TestAccSecretsManagerSecretRotation_scheduleExpression (58.07s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/secretsmanager	360.336s

@gdavison gdavison merged commit 57f45d7 into main Dec 21, 2023
37 checks passed
@gdavison gdavison deleted the b-secretsmgr-rotation branch December 21, 2023 19:06
@github-actions github-actions bot added this to the v5.32.0 milestone Dec 21, 2023
github-actions bot pushed a commit that referenced this pull request Dec 21, 2023
Copy link

This functionality has been released in v5.32.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!

@stevo-f3
Copy link

@gdavison thanks for looking into this; I've tested with v5.32.1, now schedule expression can be changed from rate to cron; still, in the apply of change from rate to cron, I got an exception with error message:

Error: updating Secrets Manager Secret Rotation (arn:aws:secretsmanager::㊙️): InvalidRequestException: A previous rotation isn't complete. That rotation will be reattempted.

Follow-up plans see the rotation schedule has been changed on AWS, so error doesn't appear again.

Not sure is there anything that can be done about this unwanted side-effect in the terraform aws provider.

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 Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/secretsmanager Issues and PRs that pertain to the secretsmanager service. size/M 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.

3 participants