provider/aws: Add update method to DB Subnet Group

This commit is contained in:
Clint Shryock 2015-08-24 16:52:30 -05:00
parent bd2adfce3b
commit fc0ccb957a
1 changed files with 27 additions and 1 deletions

View File

@ -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"},