From 21a59fc708d7cc2c602269b8408efb2bc5afbcd9 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Thu, 11 Feb 2016 16:39:53 -0600 Subject: [PATCH] provider/aws: All security group mods on first run when restoring from snapshot --- builtin/providers/aws/resource_aws_db_instance.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index e0cb1776a..c7fe72868 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -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