-
Notifications
You must be signed in to change notification settings - Fork 9k
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/ec2_transit_gateway_dx_gateway_attachement - filter support #12516
d/ec2_transit_gateway_dx_gateway_attachement - filter support #12516
Conversation
My acceptance testing: $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_ -timeout 120m
=== RUN TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_TransitGatewayIdAndDxGatewayId
=== PAUSE TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_TransitGatewayIdAndDxGatewayId
=== RUN TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter
=== PAUSE TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter
=== CONT TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_TransitGatewayIdAndDxGatewayId
=== CONT TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter
--- PASS: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_TransitGatewayIdAndDxGatewayId (1131.43s)
--- FAIL: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter (1131.90s)
testing.go:654: Step 0 error: errors during apply:
Error: error reading EC2 Transit Gateway Direct Connect Gateway Attachment: no results found
on /tmp/tf-test987078030/main.tf line 23:
(source code not available)
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 1131.949s
FAIL
GNUmakefile:26: recipe for target 'testacc' failed
make: *** [testacc] Error 1 I'll investigate the failure. |
Still get the same error if I simplify the relevant code to input := &ec2.DescribeTransitGatewayAttachmentsInput{}
input.Filters = buildEC2AttributeFilterList(map[string]string{
"resource-type": ec2.TransitGatewayAttachmentResourceTypeDirectConnectGateway,
"resource-id": d.Get("dx_gateway_id").(string),
"transit-gateway-id": d.Get("transit_gateway_id").(string),
})
input.Filters = append(input.Filters, ec2TagFiltersFromMap(d.Get("tags").(map[string]interface{}))...)
input.Filters = append(input.Filters, buildAwsDataSourceFilters(d.Get("filter").(*schema.Set))...)
if len(input.Filters) == 0 {
// Don't send an empty filters list; the EC2 API won't accept it.
input.Filters = nil
} continuing investigation... |
It's a dependency ordering in the test. Change filter {
name = "resource-id"
values = ["${aws_dx_gateway.test.id}"]
} to filter {
name = "resource-id"
values = ["${aws_dx_gateway_association.test.dx_gateway_id}"]
} and the test passes: $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter -timeout 120m
=== RUN TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter
=== PAUSE TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter
=== CONT TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter
--- PASS: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter (1153.46s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 1153.500s as the data source isn't created until the attachment has been created. |
Thanks so much @ewbankkit !!! Ive changed this accordingly |
// to preserve original functionality | ||
if dxGatewayIdOk && transitGatewayIdOk { | ||
input.Filters = []*ec2.Filter{ | ||
{ | ||
Name: aws.String("resource-id"), | ||
Values: []*string{aws.String(d.Get("dx_gateway_id").(string))}, | ||
Values: []*string{aws.String(dxGatewayId.(string))}, | ||
}, | ||
{ | ||
Name: aws.String("resource-type"), | ||
Values: []*string{aws.String("direct-connect-gateway")}, // Not yet defined in ec2/api.go. | ||
Values: []*string{aws.String(ec2.TransitGatewayAttachmentResourceTypeDirectConnectGateway)}, | ||
}, | ||
{ | ||
Name: aws.String("transit-gateway-id"), | ||
Values: []*string{aws.String(d.Get("transit_gateway_id").(string))}, | ||
Values: []*string{aws.String(transitGatewayId.(string))}, | ||
}, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as the other PR. 👍 (removing resource-type
so its not duplicated in the request)
if dxGatewayIdOk {
input.Filters = append(input.Filters, &ec2.Filter{
Name: aws.String("resource-id"),
Values: []*string{aws.String(dxGatewayId.(string))},
})
}
if transitGatewayIdOk {
input.Filters = append(input.Filters, &ec2.Filter{
Name: aws.String("transit-gateway-id"),
Values: []*string{aws.String(transitGatewayId.(string))},
})
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done + small changes to naming.
--- PASS: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_TransitGatewayIdAndDxGatewayId (1188.58s)
--- PASS: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter (1256.65s)
c323745
to
e96c40a
Compare
change test config name add tags to doc
e96c40a
to
2cf7ea7
Compare
There was a problem hiding this 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: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_filter (1163.07s)
--- PASS: TestAccAWSEc2TransitGatewayDxGatewayAttachmentDataSource_TransitGatewayIdAndDxGatewayId (1171.51s)
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! |
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! |
…source
Community Note
Relates #11994
Release note for CHANGELOG:
Output from acceptance testing: