From d713bca0532c21218f0f99690faa00259c27ec6b Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 7 Oct 2019 12:28:04 -0400 Subject: [PATCH] data-source/aws_subnet: Refactor to use keyvaluetags library Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/7926 In preparation for provider-wide ignore and default tag logic, here we refactor this resource to use the consistent `keyvaluetags` handling. Output from acceptance testing: ``` --- PASS: TestAccDataSourceAwsSubnet_basic (28.82s) --- PASS: TestAccDataSourceAwsSubnet_ipv6ByIpv6CidrBlock (46.06s) --- PASS: TestAccDataSourceAwsSubnet_ipv6ByIpv6Filter (46.30s) ``` --- aws/data_source_aws_subnet.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aws/data_source_aws_subnet.go b/aws/data_source_aws_subnet.go index 04a8cdeb7ea..064d3c25d3b 100644 --- a/aws/data_source_aws_subnet.go +++ b/aws/data_source_aws_subnet.go @@ -7,6 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func dataSourceAwsSubnet() *schema.Resource { @@ -162,7 +163,11 @@ func dataSourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error { d.Set("cidr_block", subnet.CidrBlock) d.Set("default_for_az", subnet.DefaultForAz) d.Set("state", subnet.State) - d.Set("tags", tagsToMap(subnet.Tags)) + + if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(subnet.Tags).IgnoreAws().Map()); err != nil { + return fmt.Errorf("error setting tags: %s", err) + } + d.Set("assign_ipv6_address_on_creation", subnet.AssignIpv6AddressOnCreation) d.Set("map_public_ip_on_launch", subnet.MapPublicIpOnLaunch)