provider/aws: Add update method to DB Subnet Group
This commit is contained in:
parent
bd2adfce3b
commit
fc0ccb957a
|
@ -18,6 +18,7 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
Create: resourceAwsDbSubnetGroupCreate,
|
Create: resourceAwsDbSubnetGroupCreate,
|
||||||
Read: resourceAwsDbSubnetGroupRead,
|
Read: resourceAwsDbSubnetGroupRead,
|
||||||
|
Update: resourceAwsDbSubnetGroupUpdate,
|
||||||
Delete: resourceAwsDbSubnetGroupDelete,
|
Delete: resourceAwsDbSubnetGroupDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
@ -52,7 +53,6 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
|
||||||
"subnet_ids": &schema.Schema{
|
"subnet_ids": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
|
||||||
Elem: &schema.Schema{Type: schema.TypeString},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
Set: schema.HashString,
|
Set: schema.HashString,
|
||||||
},
|
},
|
||||||
|
@ -133,6 +133,32 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
return nil
|
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 {
|
func resourceAwsDbSubnetGroupDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
stateConf := &resource.StateChangeConf{
|
stateConf := &resource.StateChangeConf{
|
||||||
Pending: []string{"pending"},
|
Pending: []string{"pending"},
|
||||||
|
|
Loading…
Reference in New Issue