Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d/aws_nat_gateway: Fix filtering and reading of tags #6231

Conversation

flosell
Copy link
Contributor

@flosell flosell commented Oct 20, 2018

Currently, tags can be defined as an argument for the aws_nat_gateway data source and are documented this way but are silently ignored when searching for the NAT Gateway. When reading NAT Gateway details, tag-values aren't populated in terraform. This PR attempts to fix this.

Changes proposed in this pull request:

  • filter for given tags when provided as attribute
  • read tags-value from API response

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsNatGateway'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccDataSourceAwsNatGateway -timeout 120m
=== RUN   TestAccDataSourceAwsNatGateway
=== PAUSE TestAccDataSourceAwsNatGateway
=== CONT  TestAccDataSourceAwsNatGateway
--- PASS: TestAccDataSourceAwsNatGateway (244.10s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	244.155s

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 20, 2018
@ghost ghost added the documentation Introduces or discusses updates to documentation. label Oct 20, 2018
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. labels Oct 25, 2018
Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one non-blocking comment. Thanks @flosell! 🚀

--- PASS: TestAccDataSourceAwsNatGateway (173.96s)

@@ -116,6 +122,7 @@ func dataSourceAwsNatGatewayRead(d *schema.ResourceData, meta interface{}) error
d.Set("state", ngw.State)
d.Set("subnet_id", ngw.SubnetId)
d.Set("vpc_id", ngw.VpcId)
d.Set("tags", tagsToMap(ngw.Tags))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using d.Set() with aggregate types (TypeList, TypeSet, TypeMap), we should perform error checking to prevent issues where the code is not properly able to set the Terraform state. e.g.

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

Since the tagsToMap() function has well established usage across other resources I won't treat this as a blocker here though. 👍

@bflad bflad added this to the v1.42.0 milestone Oct 25, 2018
@bflad bflad merged commit 34c58fb into hashicorp:master Oct 25, 2018
bflad added a commit that referenced this pull request Oct 25, 2018
@bflad
Copy link
Member

bflad commented Nov 1, 2018

This has been released in version 1.42.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants