Merge branch 'pr-4969'

* pr-4969:
  provider/aws: All security group mods on first run when restoring from snapshot
This commit is contained in:
clint shryock 2016-02-11 16:40:29 -06:00
commit 8b4a366b43
1 changed files with 8 additions and 0 deletions

View File

@ -369,12 +369,20 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.StorageType = aws.String(attr.(string))
}
log.Printf("[DEBUG] DB Instance restore from snapshot configuration: %s", opts)
_, err := conn.RestoreDBInstanceFromDBSnapshot(&opts)
if err != nil {
return fmt.Errorf("Error creating DB Instance: %s", err)
}
var sgUpdate bool
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 {
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