Skip to content

Commit

Permalink
provider: Implement ignore tags functionality across all data sources…
Browse files Browse the repository at this point in the history
… resources

Reference: #10689

Changes:

```
NOTES:

* provider: Ignore tags functionality across all resources via the provider-level `ignore_tags` configuration block has been enabled and this functionality is no longer considered in preview.

ENHANCEMENTS:

* provider: Implement ignore functionality across all data sources and resources (except aws_autoscaling_group)
```

Implements a static analysis check to verify the inclusion of the `IgnoreConfig()` call within `d.Set("tags", /* ... */)` implementations. Acceptance testing for the ignore tags functionality is handled at the provider level and only the `aws_subnet` and `aws_vpc` resources to verify. This choice was a pragmatic compromise given there is static analysis enforcement of the implementation and approved via HashiCorp RFC process.

The `aws_dynamodb_table` data source and resource were missing their `keyvaluetags` implementation. This rectifies this for consistency with the rest of the provider resources.

Output from acceptance testing (DynamoDB Tables only as smoke test and since its implementation was adjusted to keyvaluetags):

```
--- PASS: TestAccDataSourceAwsDynamoDbTable_basic (44.65s)

--- PASS: TestAccAWSDynamoDbTable_attributeUpdate (507.13s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdateValidation (6.81s)
--- PASS: TestAccAWSDynamoDbTable_basic (31.10s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_PayPerRequestToProvisioned (70.75s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_ProvisionedToPayPerRequest (1199.18s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_PayPerRequestToProvisioned (54.48s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_ProvisionedToPayPerRequest (1070.16s)
--- PASS: TestAccAWSDynamoDbTable_disappears (25.90s)
--- PASS: TestAccAWSDynamoDbTable_disappears_PayPerRequestWithGSI (78.70s)
--- PASS: TestAccAWSDynamoDbTable_enablePitr (67.70s)
--- PASS: TestAccAWSDynamoDbTable_encryption (167.85s)
--- PASS: TestAccAWSDynamoDbTable_extended (189.24s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateCapacity (72.21s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (197.54s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes (498.37s)
--- PASS: TestAccAWSDynamoDbTable_Replica (482.28s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecification (69.19s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecificationValidation (5.38s)
--- PASS: TestAccAWSDynamoDbTable_tags (50.77s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Disabled (45.57s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Enabled (31.79s)
```
  • Loading branch information
bflad committed Apr 27, 2020
1 parent dcb0096 commit f41d9a9
Show file tree
Hide file tree
Showing 289 changed files with 877 additions and 331 deletions.
10 changes: 8 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,27 @@ More details about this code generation, including fixes for potential error mes
- In the resource `Read` function, implement the logic to convert the service tags to save them into the Terraform state for drift detection, e.g. with EKS Clusters (which had the tags available in the DescribeCluster API call):

```go
if err := d.Set("tags", keyvaluetags.EksKeyValueTags(cluster.Tags).IgnoreAws().Map()); err != nil {
// Typically declared near conn := /* ... */
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

if err := d.Set("tags", keyvaluetags.EksKeyValueTags(cluster.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
```

If the service API does not return the tags directly from reading the resource and requires a separate API call, its possible to use the `keyvaluetags` functionality like the following, e.g. with Athena Workgroups:

```go
// Typically declared near conn := /* ... */
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

tags, err := keyvaluetags.AthenaListTags(conn, arn.String())

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

if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil {
if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
```
Expand Down
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ lint:
-AT007 \
-AT008 \
-AWSR001 \
-AWSR002 \
-R002 \
-R004 \
-R006 \
Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_acm_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func dataSourceAwsAcmCertificate() *schema.Resource {

func dataSourceAwsAcmCertificateRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).acmconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

params := &acm.ListCertificatesInput{}

Expand Down Expand Up @@ -177,7 +178,7 @@ func dataSourceAwsAcmCertificateRead(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("error listing tags for ACM Certificate (%s): %s", d.Id(), err)
}

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

Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_acmpca_certificate_authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func dataSourceAwsAcmpcaCertificateAuthority() *schema.Resource {

func dataSourceAwsAcmpcaCertificateAuthorityRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).acmpcaconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig
certificateAuthorityArn := d.Get("arn").(string)

describeCertificateAuthorityInput := &acmpca.DescribeCertificateAuthorityInput{
Expand Down Expand Up @@ -169,7 +170,7 @@ func dataSourceAwsAcmpcaCertificateAuthorityRead(d *schema.ResourceData, meta in
return fmt.Errorf("error listing tags for ACMPCA Certificate Authority (%s): %s", certificateAuthorityArn, err)
}

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

Expand Down
7 changes: 4 additions & 3 deletions aws/data_source_aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func dataSourceAwsAmi() *schema.Resource {
// dataSourceAwsAmiDescriptionRead performs the AMI lookup.
func dataSourceAwsAmiRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

params := &ec2.DescribeImagesInput{
Owners: expandStringList(d.Get("owners").([]interface{})),
Expand Down Expand Up @@ -237,11 +238,11 @@ func dataSourceAwsAmiRead(d *schema.ResourceData, meta interface{}) error {
})
}

return amiDescriptionAttributes(d, filteredImages[0])
return amiDescriptionAttributes(d, filteredImages[0], ignoreTagsConfig)
}

// populate the numerous fields that the image description returns.
func amiDescriptionAttributes(d *schema.ResourceData, image *ec2.Image) error {
func amiDescriptionAttributes(d *schema.ResourceData, image *ec2.Image, ignoreTagsConfig *keyvaluetags.IgnoreConfig) error {
// Simple attributes first
d.SetId(*image.ImageId)
d.Set("architecture", image.Architecture)
Expand Down Expand Up @@ -288,7 +289,7 @@ func amiDescriptionAttributes(d *schema.ResourceData, image *ec2.Image) error {
if err := d.Set("state_reason", amiStateReason(image.StateReason)); err != nil {
return err
}
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(image.Tags).IgnoreAws().Map()); err != nil {
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(image.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
return nil
Expand Down
4 changes: 3 additions & 1 deletion aws/data_source_aws_api_gateway_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func dataSourceAwsApiGatewayApiKey() *schema.Resource {

func dataSourceAwsApiGatewayApiKeyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigatewayconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

apiKey, err := conn.GetApiKey(&apigateway.GetApiKeyInput{
ApiKey: aws.String(d.Get("id").(string)),
IncludeValue: aws.Bool(true),
Expand All @@ -67,7 +69,7 @@ func dataSourceAwsApiGatewayApiKeyRead(d *schema.ResourceData, meta interface{})
d.Set("enabled", apiKey.Enabled)
d.Set("last_updated_date", aws.TimeValue(apiKey.LastUpdatedDate).Format(time.RFC3339))

if err := d.Set("tags", keyvaluetags.ApigatewayKeyValueTags(apiKey.Tags).IgnoreAws().Map()); err != nil {
if err := d.Set("tags", keyvaluetags.ApigatewayKeyValueTags(apiKey.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
return nil
Expand Down
4 changes: 3 additions & 1 deletion aws/data_source_aws_api_gateway_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ func dataSourceAwsApiGatewayRestApi() *schema.Resource {

func dataSourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigatewayconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

params := &apigateway.GetRestApisInput{}

target := d.Get("name")
Expand Down Expand Up @@ -127,7 +129,7 @@ func dataSourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{}
return fmt.Errorf("error setting endpoint_configuration: %s", err)
}

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

Expand Down
4 changes: 3 additions & 1 deletion aws/data_source_aws_api_gateway_vpc_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func dataSourceAwsApiGatewayVpcLink() *schema.Resource {

func dataSourceAwsApiGatewayVpcLinkRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigatewayconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

params := &apigateway.GetVpcLinksInput{}

target := d.Get("name")
Expand Down Expand Up @@ -81,7 +83,7 @@ func dataSourceAwsApiGatewayVpcLinkRead(d *schema.ResourceData, meta interface{}
d.Set("description", match.Description)
d.Set("target_arns", flattenStringList(match.TargetArns))

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

Expand Down
4 changes: 3 additions & 1 deletion aws/data_source_aws_cloudformation_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func dataSourceAwsCloudFormationStack() *schema.Resource {

func dataSourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).cfconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

name := d.Get("name").(string)
input := &cloudformation.DescribeStacksInput{
StackName: aws.String(name),
Expand All @@ -92,7 +94,7 @@ func dataSourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface
}

d.Set("parameters", flattenAllCloudFormationParameters(stack.Parameters))
if err := d.Set("tags", keyvaluetags.CloudformationKeyValueTags(stack.Tags).IgnoreAws().Map()); err != nil {
if err := d.Set("tags", keyvaluetags.CloudformationKeyValueTags(stack.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
d.Set("outputs", flattenCloudFormationOutputs(stack.Outputs))
Expand Down
4 changes: 3 additions & 1 deletion aws/data_source_aws_cloudfront_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func dataSourceAwsCloudFrontDistribution() *schema.Resource {
func dataSourceAwsCloudFrontDistributionRead(d *schema.ResourceData, meta interface{}) error {
d.SetId(d.Get("id").(string))
conn := meta.(*AWSClient).cloudfrontconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

input := &cloudfront.GetDistributionInput{
Id: aws.String(d.Id()),
}
Expand All @@ -85,7 +87,7 @@ func dataSourceAwsCloudFrontDistributionRead(d *schema.ResourceData, meta interf
if err != nil {
return fmt.Errorf("error listing tags for CloudFront Distribution (%s): %w", d.Id(), err)
}
if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil {
if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_cloudwatch_log_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func dataSourceAwsCloudwatchLogGroup() *schema.Resource {
func dataSourceAwsCloudwatchLogGroupRead(d *schema.ResourceData, meta interface{}) error {
name := d.Get("name").(string)
conn := meta.(*AWSClient).cloudwatchlogsconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

logGroup, err := lookupCloudWatchLogGroup(conn, name)
if err != nil {
Expand All @@ -61,7 +62,7 @@ func dataSourceAwsCloudwatchLogGroupRead(d *schema.ResourceData, meta interface{
return fmt.Errorf("error listing tags for CloudWatch Logs Group (%s): %s", name, err)
}

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

Expand Down
4 changes: 3 additions & 1 deletion aws/data_source_aws_customer_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func dataSourceAwsCustomerGateway() *schema.Resource {

func dataSourceAwsCustomerGatewayRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

input := ec2.DescribeCustomerGatewaysInput{}

if v, ok := d.GetOk("filter"); ok {
Expand Down Expand Up @@ -84,7 +86,7 @@ func dataSourceAwsCustomerGatewayRead(d *schema.ResourceData, meta interface{})
d.Set("bgp_asn", int(asn))
}

if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(cg.Tags).IgnoreAws().Map()); err != nil {
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(cg.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags for EC2 Customer Gateway %q: %s", aws.StringValue(cg.CustomerGatewayId), err)
}

Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_db_cluster_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func dataSourceAwsDbClusterSnapshot() *schema.Resource {

func dataSourceAwsDbClusterSnapshotRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

clusterIdentifier, clusterIdentifierOk := d.GetOk("db_cluster_identifier")
snapshotIdentifier, snapshotIdentifierOk := d.GetOk("db_cluster_snapshot_identifier")
Expand Down Expand Up @@ -185,7 +186,7 @@ func dataSourceAwsDbClusterSnapshotRead(d *schema.ResourceData, meta interface{}
return fmt.Errorf("error listing tags for RDS DB Cluster Snapshot (%s): %s", d.Get("db_cluster_snapshot_arn").(string), err)
}

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

Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func dataSourceAwsDbInstance() *schema.Resource {

func dataSourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

opts := &rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(d.Get("db_instance_identifier").(string)),
Expand Down Expand Up @@ -322,7 +323,7 @@ func dataSourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("error listing tags for RDS DB Instance (%s): %s", d.Get("db_instance_arn").(string), err)
}

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

Expand Down
6 changes: 4 additions & 2 deletions aws/data_source_aws_directory_service_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package aws

import (
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/directoryservice"
Expand Down Expand Up @@ -118,6 +119,7 @@ func dataSourceAwsDirectoryServiceDirectory() *schema.Resource {

func dataSourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).dsconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

directoryID := d.Get("directory_id").(string)
out, err := conn.DescribeDirectories(&directoryservice.DescribeDirectoriesInput{
Expand Down Expand Up @@ -167,7 +169,7 @@ func dataSourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta int
return fmt.Errorf("error listing tags for Directory Service Directory (%s): %s", d.Id(), err)
}

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

Expand Down
14 changes: 10 additions & 4 deletions aws/data_source_aws_dynamodb_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsDynamoDbTable() *schema.Resource {
Expand Down Expand Up @@ -213,6 +214,7 @@ func dataSourceAwsDynamoDbTable() *schema.Resource {

func dataSourceAwsDynamoDbTableRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).dynamodbconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

result, err := conn.DescribeTable(&dynamodb.DescribeTableInput{
TableName: aws.String(d.Get("name").(string)),
Expand All @@ -239,11 +241,15 @@ func dataSourceAwsDynamoDbTableRead(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("error setting ttl: %s", err)
}

tags, err := readDynamoDbTableTags(d.Get("arn").(string), conn)
if err != nil {
return err
tags, err := keyvaluetags.DynamodbListTags(conn, d.Get("arn").(string))

if err != nil && !isAWSErr(err, "UnknownOperationException", "Tagging is not currently supported in DynamoDB Local.") {
return fmt.Errorf("error listing tags for DynamoDB Table (%s): %s", d.Get("arn").(string), err)
}

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

pitrOut, err := conn.DescribeContinuousBackups(&dynamodb.DescribeContinuousBackupsInput{
TableName: aws.String(d.Id()),
Expand Down
7 changes: 4 additions & 3 deletions aws/data_source_aws_ebs_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func dataSourceAwsEbsSnapshot() *schema.Resource {

func dataSourceAwsEbsSnapshotRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

restorableUsers, restorableUsersOk := d.GetOk("restorable_by_user_ids")
filters, filtersOk := d.GetOk("filter")
Expand Down Expand Up @@ -131,10 +132,10 @@ func dataSourceAwsEbsSnapshotRead(d *schema.ResourceData, meta interface{}) erro
}

//Single Snapshot found so set to state
return snapshotDescriptionAttributes(d, resp.Snapshots[0])
return snapshotDescriptionAttributes(d, resp.Snapshots[0], ignoreTagsConfig)
}

func snapshotDescriptionAttributes(d *schema.ResourceData, snapshot *ec2.Snapshot) error {
func snapshotDescriptionAttributes(d *schema.ResourceData, snapshot *ec2.Snapshot, ignoreTagsConfig *keyvaluetags.IgnoreConfig) error {
d.SetId(*snapshot.SnapshotId)
d.Set("snapshot_id", snapshot.SnapshotId)
d.Set("volume_id", snapshot.VolumeId)
Expand All @@ -147,7 +148,7 @@ func snapshotDescriptionAttributes(d *schema.ResourceData, snapshot *ec2.Snapsho
d.Set("owner_id", snapshot.OwnerId)
d.Set("owner_alias", snapshot.OwnerAlias)

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

Expand Down
2 changes: 1 addition & 1 deletion aws/data_source_aws_ebs_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func volumeDescriptionAttributes(d *schema.ResourceData, client *AWSClient, volu
d.Set("snapshot_id", volume.SnapshotId)
d.Set("volume_type", volume.VolumeType)

if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(volume.Tags).IgnoreAws().Map()); err != nil {
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(volume.Tags).IgnoreAws().IgnoreConfig(client.IgnoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_ec2_transit_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func dataSourceAwsEc2TransitGateway() *schema.Resource {

func dataSourceAwsEc2TransitGatewayRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

input := &ec2.DescribeTransitGatewaysInput{}

Expand Down Expand Up @@ -119,7 +120,7 @@ func dataSourceAwsEc2TransitGatewayRead(d *schema.ResourceData, meta interface{}
d.Set("owner_id", transitGateway.OwnerId)
d.Set("propagation_default_route_table_id", transitGateway.Options.PropagationDefaultRouteTableId)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func dataSourceAwsEc2TransitGatewayDxGatewayAttachment() *schema.Resource {

func dataSourceAwsEc2TransitGatewayDxGatewayAttachmentRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

filters, filtersOk := d.GetOk("filter")
tags, tagsOk := d.GetOk("tags")
Expand Down Expand Up @@ -84,7 +85,7 @@ func dataSourceAwsEc2TransitGatewayDxGatewayAttachmentRead(d *schema.ResourceDat

transitGatewayAttachment := output.TransitGatewayAttachments[0]

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

Expand Down
Loading

0 comments on commit f41d9a9

Please sign in to comment.