Support tags for aws_db_subnet_group
This commit is contained in:
parent
7d142134f2
commit
72e421942e
|
@ -56,12 +56,15 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
|
||||||
Elem: &schema.Schema{Type: schema.TypeString},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
Set: schema.HashString,
|
Set: schema.HashString,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"tags": tagsSchema(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
rdsconn := meta.(*AWSClient).rdsconn
|
rdsconn := meta.(*AWSClient).rdsconn
|
||||||
|
tags := tagsFromMapRDS(d.Get("tags").(map[string]interface{}))
|
||||||
|
|
||||||
subnetIdsSet := d.Get("subnet_ids").(*schema.Set)
|
subnetIdsSet := d.Get("subnet_ids").(*schema.Set)
|
||||||
subnetIds := make([]*string, subnetIdsSet.Len())
|
subnetIds := make([]*string, subnetIdsSet.Len())
|
||||||
|
@ -73,6 +76,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
DBSubnetGroupName: aws.String(d.Get("name").(string)),
|
DBSubnetGroupName: aws.String(d.Get("name").(string)),
|
||||||
DBSubnetGroupDescription: aws.String(d.Get("description").(string)),
|
DBSubnetGroupDescription: aws.String(d.Get("description").(string)),
|
||||||
SubnetIds: subnetIds,
|
SubnetIds: subnetIds,
|
||||||
|
Tags: tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Create DB Subnet Group: %#v", createOpts)
|
log.Printf("[DEBUG] Create DB Subnet Group: %#v", createOpts)
|
||||||
|
@ -130,6 +134,28 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
}
|
}
|
||||||
d.Set("subnet_ids", subnets)
|
d.Set("subnet_ids", subnets)
|
||||||
|
|
||||||
|
// list tags for resource
|
||||||
|
// set tags
|
||||||
|
conn := meta.(*AWSClient).rdsconn
|
||||||
|
arn, err := buildRDSARN(d, meta)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[DEBUG] Error building ARN for DB Subnet Group, not setting Tags for group %s", subnetGroup.DBSubnetGroupName)
|
||||||
|
} else {
|
||||||
|
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
|
||||||
|
ResourceName: aws.String(arn),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[DEBUG] Error retreiving tags for ARN: %s", arn)
|
||||||
|
}
|
||||||
|
|
||||||
|
var dt []*rds.Tag
|
||||||
|
if len(resp.TagList) > 0 {
|
||||||
|
dt = resp.TagList
|
||||||
|
}
|
||||||
|
d.Set("tags", tagsToMapRDS(dt))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,9 @@ resource "aws_db_subnet_group" "foo" {
|
||||||
name = "FOO"
|
name = "FOO"
|
||||||
description = "foo description"
|
description = "foo description"
|
||||||
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
|
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
|
||||||
|
tags {
|
||||||
|
Name = "tf-dbsubnet-group-test"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ resource "aws_db_subnet_group" "default" {
|
||||||
name = "main"
|
name = "main"
|
||||||
description = "Our main group of subnets"
|
description = "Our main group of subnets"
|
||||||
subnet_ids = ["${aws_subnet.frontend.id}", "${aws_subnet.backend.id}"]
|
subnet_ids = ["${aws_subnet.frontend.id}", "${aws_subnet.backend.id}"]
|
||||||
|
tags {
|
||||||
|
Name = "My DB subnet group"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -27,6 +30,7 @@ The following arguments are supported:
|
||||||
* `name` - (Required) The name of the DB subnet group.
|
* `name` - (Required) The name of the DB subnet group.
|
||||||
* `description` - (Required) The description of the DB subnet group.
|
* `description` - (Required) The description of the DB subnet group.
|
||||||
* `subnet_ids` - (Required) A list of VPC subnet IDs.
|
* `subnet_ids` - (Required) A list of VPC subnet IDs.
|
||||||
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue