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_db_option_group: Fix error when creating db_option_group with new IAM role #5389

Merged
merged 2 commits into from
Jul 31, 2018

Conversation

pvanbuijtene
Copy link
Contributor

Fixes #763

Added retry to fix eventual consistency error when referring to new IAM role.

Output from acceptance testing:

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run .*AWSDBOptionGroup.* -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSDBOptionGroup_importBasic
--- PASS: TestAccAWSDBOptionGroup_importBasic (30.90s)
=== RUN   TestAccAWSDBOptionGroup_basic
--- PASS: TestAccAWSDBOptionGroup_basic (26.91s)
=== RUN   TestAccAWSDBOptionGroup_timeoutBlock
--- PASS: TestAccAWSDBOptionGroup_timeoutBlock (28.20s)
=== RUN   TestAccAWSDBOptionGroup_namePrefix
--- PASS: TestAccAWSDBOptionGroup_namePrefix (26.76s)
=== RUN   TestAccAWSDBOptionGroup_generatedName
--- PASS: TestAccAWSDBOptionGroup_generatedName (32.78s)
=== RUN   TestAccAWSDBOptionGroup_defaultDescription
--- PASS: TestAccAWSDBOptionGroup_defaultDescription (27.49s)
=== RUN   TestAccAWSDBOptionGroup_basicDestroyWithInstance
--- PASS: TestAccAWSDBOptionGroup_basicDestroyWithInstance (501.20s)
=== RUN   TestAccAWSDBOptionGroup_OptionSettings
--- PASS: TestAccAWSDBOptionGroup_OptionSettings (49.78s)
=== RUN   TestAccAWSDBOptionGroup_OptionSettingsIAMRole
--- PASS: TestAccAWSDBOptionGroup_OptionSettingsIAMRole (48.33s)
=== RUN   TestAccAWSDBOptionGroup_sqlServerOptionsUpdate
--- PASS: TestAccAWSDBOptionGroup_sqlServerOptionsUpdate (48.33s)
=== RUN   TestAccAWSDBOptionGroup_OracleOptionsUpdate
--- PASS: TestAccAWSDBOptionGroup_OracleOptionsUpdate (60.62s)
=== RUN   TestAccAWSDBOptionGroup_multipleOptions
--- PASS: TestAccAWSDBOptionGroup_multipleOptions (28.57s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	909.939s

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jul 30, 2018
@pvanbuijtene pvanbuijtene changed the title Fix error when creating db_option_group with new IAM role resource/aws_db_option_group: Fix error when creating db_option_group with new IAM role Jul 30, 2018
@bflad bflad added bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service. labels Jul 30, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

This is looking really good, @pvanbuijtene! Left two notes below. Let me know if you have any questions or do not have time to implement the feedback. 👍

@@ -273,12 +273,24 @@ func resourceAwsDbOptionGroupUpdate(d *schema.ResourceData, meta interface{}) er
}

log.Printf("[DEBUG] Modify DB Option Group: %s", modifyOpts)
_, err = rdsconn.ModifyOptionGroup(modifyOpts)

err = resource.Retry(5*time.Minute, func() *resource.RetryError {
Copy link
Contributor

Choose a reason for hiding this comment

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

IAM eventual consistency is usually on the magnitude of 1-2 minutes (very rarely the latter). Can you please lower this retry timeout to prevent bad user experience when there might be an actual issue?


_, err = rdsconn.ModifyOptionGroup(modifyOpts)
if err != nil {
if isAWSErr(err, "InvalidParameterValue", "SQLSERVER_BACKUP_RESTORE") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Two things:

  • Can you please add a comment with the full error message?
  • Can you adjust the string checking for the relevant IAM part, instead of just the parameter in question? We don't want to retry on non-IAM messages for SQLSERVER_BACKUP_RESTORE and we also would love to proactively catch IAM issues for other parameters if we can.

e.g.

// InvalidParameterValue: IAM role ARN value is invalid or does not include the required permissions for: SQLSERVER_BACKUP_RESTORE
if isAWSErr(err, "InvalidParameterValue", "IAM role ARN value is invalid or does not include the required permissions") {

@ghost ghost added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jul 30, 2018
@pvanbuijtene
Copy link
Contributor Author

@bflad thanks for the review, review comments are applied.

@bflad bflad added this to the v1.30.0 milestone Jul 31, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks great @pvanbuijtene, thanks!! 🚀

12 tests passed (all tests)
=== RUN   TestAccAWSDBOptionGroup_defaultDescription
--- PASS: TestAccAWSDBOptionGroup_defaultDescription (7.09s)
=== RUN   TestAccAWSDBOptionGroup_generatedName
--- PASS: TestAccAWSDBOptionGroup_generatedName (7.18s)
=== RUN   TestAccAWSDBOptionGroup_namePrefix
--- PASS: TestAccAWSDBOptionGroup_namePrefix (7.29s)
=== RUN   TestAccAWSDBOptionGroup_timeoutBlock
--- PASS: TestAccAWSDBOptionGroup_timeoutBlock (7.36s)
=== RUN   TestAccAWSDBOptionGroup_multipleOptions
--- PASS: TestAccAWSDBOptionGroup_multipleOptions (7.43s)
=== RUN   TestAccAWSDBOptionGroup_importBasic
--- PASS: TestAccAWSDBOptionGroup_importBasic (7.98s)
=== RUN   TestAccAWSDBOptionGroup_OptionSettings
--- PASS: TestAccAWSDBOptionGroup_OptionSettings (12.11s)
=== RUN   TestAccAWSDBOptionGroup_OracleOptionsUpdate
--- PASS: TestAccAWSDBOptionGroup_OracleOptionsUpdate (13.44s)
=== RUN   TestAccAWSDBOptionGroup_basic
--- PASS: TestAccAWSDBOptionGroup_basic (14.34s)
=== RUN   TestAccAWSDBOptionGroup_sqlServerOptionsUpdate
--- PASS: TestAccAWSDBOptionGroup_sqlServerOptionsUpdate (26.08s)
=== RUN   TestAccAWSDBOptionGroup_OptionSettingsIAMRole
--- PASS: TestAccAWSDBOptionGroup_OptionSettingsIAMRole (27.43s)
=== RUN   TestAccAWSDBOptionGroup_basicDestroyWithInstance
--- PASS: TestAccAWSDBOptionGroup_basicDestroyWithInstance (483.67s)

@bflad bflad merged commit 7045783 into hashicorp:master Jul 31, 2018
bflad added a commit that referenced this pull request Jul 31, 2018
@bflad
Copy link
Contributor

bflad commented Aug 2, 2018

This has been released in version 1.30.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 4, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
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/rds Issues and PRs that pertain to the rds service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DB option groups with a failed IAM-related option apply do not detect missing options in subsqeuent plan
2 participants