Skip to content

Commit

Permalink
Merge pull request #5113 from saravanan30erd/db_subnet_group
Browse files Browse the repository at this point in the history
set arn attribute from DB subnet group response instead of arn endpoint
  • Loading branch information
bflad authored Jul 6, 2018
2 parents c82c9e8 + 1642c12 commit ae2f085
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 2 additions & 15 deletions aws/resource_aws_db_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/rds"

Expand Down Expand Up @@ -151,13 +150,7 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
// set tags
conn := meta.(*AWSClient).rdsconn

arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "rds",
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
Resource: fmt.Sprintf("subgrp:%s", d.Id()),
}.String()
arn := aws.StringValue(subnetGroup.DBSubnetGroupArn)
d.Set("arn", arn)
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
ResourceName: aws.String(arn),
Expand Down Expand Up @@ -201,13 +194,7 @@ func resourceAwsDbSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) er
}
}

arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "rds",
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
Resource: fmt.Sprintf("subgrp:%s", d.Id()),
}.String()
arn := d.Get("arn").(string)
if err := setTagsRDS(conn, d, arn); err != nil {
return err
} else {
Expand Down
2 changes: 2 additions & 0 deletions aws/resource_aws_db_subnet_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func TestAccAWSDBSubnetGroup_basic(t *testing.T) {
"aws_db_subnet_group.foo", "name", rName),
resource.TestCheckResourceAttr(
"aws_db_subnet_group.foo", "description", "Managed by Terraform"),
resource.TestMatchResourceAttr(
"aws_db_subnet_group.foo", "arn", regexp.MustCompile(fmt.Sprintf("^arn:[^:]+:rds:[^:]+:\\d{12}:subgrp:%s", rName))),
testCheck,
),
},
Expand Down

0 comments on commit ae2f085

Please sign in to comment.