diff --git a/aws/resource_aws_db_instance.go b/aws/resource_aws_db_instance.go index b52d856a1e28..8189ecf4a82d 100644 --- a/aws/resource_aws_db_instance.go +++ b/aws/resource_aws_db_instance.go @@ -500,50 +500,30 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error creating DB Instance: %s", err) } - var sgUpdate bool - var passwordUpdate bool + // wait for instance to get up and then modify + d.SetId(d.Get("identifier").(string)) - if _, ok := d.GetOk("password"); ok { - passwordUpdate = true - } - - if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 { - sgUpdate = true - } - if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 { - sgUpdate = true - } - if sgUpdate || passwordUpdate { - log.Printf("[INFO] DB is restoring from snapshot with default security, but custom security should be set, will now update after snapshot is restored!") - - // wait for instance to get up and then modify security - d.SetId(d.Get("identifier").(string)) + log.Printf("[INFO] DB Instance ID: %s", d.Id()) - log.Printf("[INFO] DB Instance ID: %s", d.Id()) - - log.Println( - "[INFO] Waiting for DB Instance to be available") - - stateConf := &resource.StateChangeConf{ - Pending: resourceAwsDbInstanceCreatePendingStates, - Target: []string{"available", "storage-optimization"}, - Refresh: resourceAwsDbInstanceStateRefreshFunc(d.Id(), conn), - Timeout: d.Timeout(schema.TimeoutCreate), - MinTimeout: 10 * time.Second, - Delay: 30 * time.Second, // Wait 30 secs before starting - } + log.Println("[INFO] Waiting for DB Instance to be available") - // Wait, catching any errors - _, err := stateConf.WaitForState() - if err != nil { - return err - } + stateConf := &resource.StateChangeConf{ + Pending: resourceAwsDbInstanceCreatePendingStates, + Target: []string{"available", "storage-optimization"}, + Refresh: resourceAwsDbInstanceStateRefreshFunc(d.Id(), conn), + Timeout: d.Timeout(schema.TimeoutCreate), + MinTimeout: 10 * time.Second, + Delay: 30 * time.Second, // Wait 30 secs before starting + } - err = resourceAwsDbInstanceUpdate(d, meta) - if err != nil { - return err - } + // Wait, catching any errors + _, err = stateConf.WaitForState() + if err != nil { + return err + } + if err = resourceAwsDbInstanceUpdate(d, meta); err != nil { + return err } } else { if _, ok := d.GetOk("allocated_storage"); !ok {