Skip to content

Commit

Permalink
use keyvaluetags (#10724)
Browse files Browse the repository at this point in the history
Output from acceptance testing:

```
--- PASS: TestAccDataSourceAWSRDSCluster_basic (134.99s)
```
  • Loading branch information
DrFaust92 authored and bflad committed Nov 4, 2019
1 parent 033c2be commit 3d37901
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions aws/data_source_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsRdsCluster() *schema.Resource {
Expand Down Expand Up @@ -201,7 +202,8 @@ func dataSourceAwsRdsClusterRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("error setting availability_zones: %s", err)
}

d.Set("arn", dbc.DBClusterArn)
arn := dbc.DBClusterArn
d.Set("arn", arn)
d.Set("backtrack_window", int(aws.Int64Value(dbc.BacktrackWindow)))
d.Set("backup_retention_period", dbc.BackupRetentionPeriod)
d.Set("cluster_identifier", dbc.DBClusterIdentifier)
Expand Down Expand Up @@ -263,9 +265,14 @@ func dataSourceAwsRdsClusterRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("error setting vpc_security_group_ids: %s", err)
}

// Fetch and save tags
if err := saveTagsRDS(conn, d, aws.StringValue(dbc.DBClusterArn)); err != nil {
log.Printf("[WARN] Failed to save tags for RDS Cluster (%s): %s", aws.StringValue(dbc.DBClusterIdentifier), err)
tags, err := keyvaluetags.RdsListTags(conn, *arn)

if err != nil {
return fmt.Errorf("error listing tags for RDS Cluster (%s): %s", *arn, err)
}

if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

return nil
Expand Down

0 comments on commit 3d37901

Please sign in to comment.