Skip to content

fix: Fixed service_region argument in the VPC endpoint module #1162

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/vpc-endpoints/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data "aws_vpc_endpoint_service" "this" {

service = try(each.value.service, null)
service_name = try(each.value.service_name, null)
service_regions = try([each.value.service_region], null)
service_regions = try(each.value.service_region != null ? [each.value.service_region] : null, null)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
service_regions = try(each.value.service_region != null ? [each.value.service_region] : null, null)
service_regions = one([each.value.service_region])

Much simpler, but please test it. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. So I tested

service_regions = one([each.value.service_region])

this does not quite work. If the endpoints maps' service_region value is a valid string, it evaluates just to the string, but the data sources' service_regions expects a list of strings. Further, if service _region is not included in the endpoints map, it also fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could change it to this which is a bit easier to understand and read and I successfully tested for all 3 cases (service_region not included in the endpoints map, service_region=null or service_region="valid-region-string":

service_regions = try(each.value.service_region, null) != null ? [each.value.service_region] : null

Copy link
Member

Choose a reason for hiding this comment

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

I think this is going to work as expected:

service_regions = try(coalescelist(compact([each.value.service_region])), null)

Let's use it if it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does indeed, thank you! Updated the PR accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for fixing an issue!


filter {
name = "service-type"
Expand Down
Loading