Skip to content

Commit

Permalink
data-source/aws_vpc: Refactor to use keyvaluetags library (#10413)
Browse files Browse the repository at this point in the history
Reference: #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: TestAccDataSourceAwsVpc_basic (27.54s)
--- PASS: TestAccDataSourceAwsVpc_ipv6Associated (27.56s)
--- PASS: TestAccDataSourceAwsVpc_multipleCidr (51.12s)
```
  • Loading branch information
bflad authored Oct 25, 2019
2 parents dd2020c + 557d865 commit 0996270
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aws/data_source_aws_vpc.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/arn"
"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 dataSourceAwsVpc() *schema.Resource {
Expand Down Expand Up @@ -176,7 +177,11 @@ func dataSourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
d.Set("instance_tenancy", vpc.InstanceTenancy)
d.Set("default", vpc.IsDefault)
d.Set("state", vpc.State)
d.Set("tags", tagsToMap(vpc.Tags))

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

d.Set("owner_id", vpc.OwnerId)

arn := arn.ARN{
Expand Down

0 comments on commit 0996270

Please # to comment.