Skip to content

Commit 21a59fc

Browse files
committed
provider/aws: All security group mods on first run when restoring from snapshot
1 parent cfafa3f commit 21a59fc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

builtin/providers/aws/resource_aws_db_instance.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,20 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
369369
opts.StorageType = aws.String(attr.(string))
370370
}
371371

372+
log.Printf("[DEBUG] DB Instance restore from snapshot configuration: %s", opts)
372373
_, err := conn.RestoreDBInstanceFromDBSnapshot(&opts)
373374
if err != nil {
374375
return fmt.Errorf("Error creating DB Instance: %s", err)
375376
}
376377

378+
var sgUpdate bool
377379
if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 {
380+
sgUpdate = true
381+
}
382+
if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 {
383+
sgUpdate = true
384+
}
385+
if sgUpdate {
378386
log.Printf("[INFO] DB is restoring from snapshot with default security, but custom security should be set, will now update after snapshot is restored!")
379387

380388
// wait for instance to get up and then modify security

0 commit comments

Comments
 (0)