From fc0ccb957a496274586fcc4d1c45650999c3e7e5 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Mon, 24 Aug 2015 16:52:30 -0500 Subject: [PATCH] provider/aws: Add update method to DB Subnet Group --- .../aws/resource_aws_db_subnet_group.go | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_db_subnet_group.go b/builtin/providers/aws/resource_aws_db_subnet_group.go index 3d8ebc833..9c09b72d7 100644 --- a/builtin/providers/aws/resource_aws_db_subnet_group.go +++ b/builtin/providers/aws/resource_aws_db_subnet_group.go @@ -18,6 +18,7 @@ func resourceAwsDbSubnetGroup() *schema.Resource { return &schema.Resource{ Create: resourceAwsDbSubnetGroupCreate, Read: resourceAwsDbSubnetGroupRead, + Update: resourceAwsDbSubnetGroupUpdate, Delete: resourceAwsDbSubnetGroupDelete, Schema: map[string]*schema.Schema{ @@ -52,7 +53,6 @@ func resourceAwsDbSubnetGroup() *schema.Resource { "subnet_ids": &schema.Schema{ Type: schema.TypeSet, Required: true, - ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, @@ -133,6 +133,32 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro return nil } +func resourceAwsDbSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).rdsconn + if d.HasChange("subnet_ids") { + _, n := d.GetChange("subnet_ids") + if n == nil { + n = new(schema.Set) + } + ns := n.(*schema.Set) + + var sIds []*string + for _, s := range ns.List() { + sIds = append(sIds, aws.String(s.(string))) + } + + _, err := conn.ModifyDBSubnetGroup(&rds.ModifyDBSubnetGroupInput{ + DBSubnetGroupName: aws.String(d.Id()), + SubnetIds: sIds, + }) + + if err != nil { + return err + } + } + return resourceAwsDbSubnetGroupRead(d, meta) +} + func resourceAwsDbSubnetGroupDelete(d *schema.ResourceData, meta interface{}) error { stateConf := &resource.StateChangeConf{ Pending: []string{"pending"},