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

service/secretsmanager: Handle additional scheduled/marked for deletion error messages #8219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aws/resource_aws_secretsmanager_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ func resourceAwsSecretsManagerSecretCreate(d *schema.ResourceData, meta interfac
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
var err error
output, err = conn.CreateSecret(input)
// Temporarily retry on these errors to support immediate secret recreation:
// InvalidRequestException: You can’t perform this operation on the secret because it was deleted.
if isAWSErr(err, secretsmanager.ErrCodeInvalidRequestException, "You can’t perform this operation on the secret because it was deleted") {
// InvalidRequestException: You can't create this secret because a secret with this name is already scheduled for deletion.
if isAWSErr(err, secretsmanager.ErrCodeInvalidRequestException, "scheduled for deletion") || isAWSErr(err, secretsmanager.ErrCodeInvalidRequestException, "was deleted") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you encounter while running acceptance tests or was this documented in the SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Acceptance testing:

--- FAIL: TestAccAwsSecretsManagerSecret_RecoveryWindowInDays_Recreate (6.87s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
          * aws_secretsmanager_secret.test: 1 error occurred:
          * aws_secretsmanager_secret.test: error creating Secrets Manager Secret: InvalidRequestException: You can't create this secret because a secret with this name is already scheduled for deletion.

return resource.RetryableError(err)
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_secretsmanager_secret_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func testAccCheckAwsSecretsManagerSecretVersionDestroy(s *terraform.State) error
if isAWSErr(err, secretsmanager.ErrCodeResourceNotFoundException, "") {
return nil
}
if isAWSErr(err, secretsmanager.ErrCodeInvalidRequestException, "You can’t perform this operation on the secret because it was deleted") {
if isAWSErr(err, secretsmanager.ErrCodeInvalidRequestException, "was deleted") || isAWSErr(err, secretsmanager.ErrCodeInvalidRequestException, "was marked for deletion") {
return nil
}
return err
Expand Down