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_ec2_transit_gateway_vpn_attachment - filter support #12415

Merged

Conversation

DrFaust92
Copy link
Collaborator

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #11994

Release note for CHANGELOG:

data_source_aws_ec2_transit_gateway_vpn_attachment - add filter support

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_'
--- PASS: TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_TransitGatewayIdAndVpnConnectionId (615.86s)
--- PASS: TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_filter (482.38s)

@DrFaust92 DrFaust92 requested a review from a team March 16, 2020 19:59
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. labels Mar 16, 2020
@ewbankkit
Copy link
Contributor

Verified acceptance tests:

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

@bflad bflad self-assigned this Mar 25, 2020
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 25, 2020
@bflad bflad added this to the v2.55.0 milestone Mar 26, 2020
Comment on lines 56 to 72
// to preserve original functionality
if connectionIdOk && transitGatewayIdOk {
input.Filters = []*ec2.Filter{
{
Name: aws.String("resource-id"),
Values: []*string{aws.String(d.Get("vpn_connection_id").(string))},
Values: []*string{aws.String(connectionId.(string))},
},
{
Name: aws.String("resource-type"),
Values: []*string{aws.String(ec2.TransitGatewayAttachmentResourceTypeVpn)},
},
{
Name: aws.String("transit-gateway-id"),
Values: []*string{aws.String(d.Get("transit_gateway_id").(string))},
Values: []*string{aws.String(transitGatewayId.(string))},
},
},
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it could cause the unexpected consequence of removing configured filter options by overwriting the input.Filters parameter when all three are provided. I would recommend switching this to append() instead. 👍

	if connectionIdOk {
		input.Filters = append(input.Filters, &ec2.Filter{
			Name:   aws.String("resource-id"),
			Values: []*string{aws.String(connectionId.(string))},
		})
	}

	if transitGatewayIdOk {
		input.Filters = append(input.Filters, &ec2.Filter{
			Name:   aws.String("transit-gateway-id"),
			Values: []*string{aws.String(transitGatewayId.(string))},
		})
	}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

gotcha

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done,

--- PASS: TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_TransitGatewayIdAndVpnConnectionId (501.92s)
--- PASS: TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_filter (624.90s)

@bflad bflad removed this from the v2.55.0 milestone Mar 26, 2020
@DrFaust92 DrFaust92 requested a review from bflad March 26, 2020 15:08
@bflad bflad added this to the v2.55.0 milestone Mar 26, 2020
Copy link
Contributor

@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.

Looks great, thanks @DrFaust92 🚀

Output from acceptance testing:

--- PASS: TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_filter (470.70s)
--- PASS: TestAccAWSEc2TransitGatewayVpnAttachmentDataSource_TransitGatewayIdAndVpnConnectionId (529.23s)

@bflad bflad merged commit fa932b0 into hashicorp:master Mar 26, 2020
bflad added a commit that referenced this pull request Mar 26, 2020
@DrFaust92 DrFaust92 deleted the d/transit_gateway_vpn_attachment-filter branch March 27, 2020 18:37
@ghost
Copy link

ghost commented Mar 27, 2020

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Apr 25, 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 25, 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/M 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

3 participants