From 5ece0f2d0466bb52b6a1801e9c31b6eb575211db Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Mon, 9 Jan 2017 19:10:13 +0000 Subject: [PATCH] provider/aws: aws_db_instance restored from snapshot had problem with (#11050) subnet_group Fixes #11024 A change was introduced in 0.8.2 that allows db_instances to change their db_subnet_group. Unfortunately, this caused an issue for db_instances that were being restored from snapshot. The restore from snapshot part of create calls the Update func whereas a normal create calls the Read func When calling the Update func, the db_instance was trying to go through a db_subnet_group_name change and was failing for the following reason: ``` InvalidVPCNetworkStateFault: You cannot move DB instance _rds_instance_name_ to subnet group _subnet_group_name_. The specified DB subnet group and DB instance are in the same VPC. Choose a DB subnet group in different VPC than the specified DB instance and try again. ``` --- builtin/providers/aws/resource_aws_db_instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 576c2e286a..d20d533793 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -943,7 +943,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error req.DBPortNumber = aws.Int64(int64(d.Get("port").(int))) requestUpdate = true } - if d.HasChange("db_subnet_group_name") { + if d.HasChange("db_subnet_group_name") && !d.IsNewResource() { d.SetPartial("db_subnet_group_name") req.DBSubnetGroupName = aws.String(d.Get("db_subnet_group_name").(string)) requestUpdate = true