From c29e1f24b8210c6131231cf3229bdb942106159f Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 8 Mar 2016 14:08:20 -0600 Subject: [PATCH] provider/aws: Retry DB Creation on IAM propigation error --- builtin/providers/aws/resource_aws_db_instance.go | 13 ++++++++++++- .../providers/aws/resource_aws_db_instance_test.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index e6e1e7bbc40d..bd9f950ca5e5 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -534,7 +534,18 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] DB Instance create configuration: %#v", opts) var err error - _, err = conn.CreateDBInstance(&opts) + err = resource.Retry(5*time.Minute, func() error { + _, err = conn.CreateDBInstance(&opts) + if err != nil { + if awsErr, ok := err.(awserr.Error); ok { + if awsErr.Code() == "InvalidParameterValue" && strings.Contains(awsErr.Message(), "ENHANCED_MONITORING") { + return awsErr + } + } + return resource.RetryError{Err: err} + } + return nil + }) if err != nil { return fmt.Errorf("Error creating DB Instance: %s", err) } diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index f0f40ab7546d..e8dbf9df6f3c 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -514,7 +514,7 @@ resource "aws_db_instance" "enhanced_monitoring" { allocated_storage = 5 engine = "mysql" engine_version = "5.6.21" - instance_class = "db.t2.small" + instance_class = "db.m3.medium" name = "baz" password = "barbarbarbar" username = "foo"