diff --git a/aws/data_source_aws_db_instance.go b/aws/data_source_aws_db_instance.go index 7ae64cf3f49..acc51f7794c 100644 --- a/aws/data_source_aws_db_instance.go +++ b/aws/data_source_aws_db_instance.go @@ -20,6 +20,8 @@ func dataSourceAwsDbInstance() *schema.Resource { ForceNew: true, }, + "tags": tagsSchemaComputed(), + "address": { Type: schema.TypeString, Computed: true, @@ -313,5 +315,10 @@ func dataSourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting vpc_security_groups attribute: %#v, error: %#v", vpcSecurityGroups, err) } + // Fetch and save tags + if err := saveTagsRDS(conn, d, aws.StringValue(dbInstance.DBInstanceArn)); err != nil { + log.Printf("[WARN] Failed to save tags for RDS Instance (%s): %s", aws.StringValue(dbInstance.DBInstanceArn), err) + } + return nil } diff --git a/aws/data_source_aws_db_instance_test.go b/aws/data_source_aws_db_instance_test.go index 1a9dd9a4383..1ab32a59f77 100644 --- a/aws/data_source_aws_db_instance_test.go +++ b/aws/data_source_aws_db_instance_test.go @@ -31,6 +31,8 @@ func TestAccAWSDbInstanceDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrSet("data.aws_db_instance.bar", "enabled_cloudwatch_logs_exports.0"), resource.TestCheckResourceAttrSet("data.aws_db_instance.bar", "enabled_cloudwatch_logs_exports.1"), resource.TestCheckResourceAttrPair("data.aws_db_instance.bar", "resource_id", "aws_db_instance.bar", "resource_id"), + resource.TestCheckResourceAttrPair("data.aws_db_instance.bar", "tags.%", "aws_db_instance.bar", "tags.%"), + resource.TestCheckResourceAttrPair("data.aws_db_instance.bar", "tags.Environment", "aws_db_instance.bar", "tags.Environment"), ), }, }, @@ -77,6 +79,10 @@ resource "aws_db_instance" "bar" { "audit", "error", ] + + tags = { + Environment = "test" + } } data "aws_db_instance" "bar" {