-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Notice: aws_vpc_endpoint_service
: Error: multiple VPC Endpoint Services matched
#17417
Comments
if you are using a provider version prior to v3 this won't work for data "aws_region" "current" {}
data "aws_vpc_endpoint_service" "s3" {
count = var.create_vpc && var.enable_s3_endpoint ? 1 : 0
service = "s3"
filter {
name = "service-name"
values = ["com.amazonaws.${data.aws_region.current.name}.s3"]
}
} Result:
When running {
"ServiceName": "com.amazonaws.us-east-1.s3",
"ServiceId": "vpce-svc-*****",
"ServiceType": [
{
"ServiceType": "Gateway"
}
],
"AvailabilityZones": [
"us-east-1a",
"us-east-1b",
"us-east-1c",
"us-east-1d",
"us-east-1e",
"us-east-1f"
],
"Owner": "amazon",
"BaseEndpointDnsNames": [
"s3.us-east-1.amazonaws.com"
],
"VpcEndpointPolicySupported": true,
"AcceptanceRequired": false,
"ManagesVpcEndpoints": false,
"Tags": []
},
{
"ServiceName": "com.amazonaws.us-east-1.s3",
"ServiceId": "vpce-svc-****",
"ServiceType": [
{
"ServiceType": "Interface"
}
],
"AvailabilityZones": [
"us-east-1a",
"us-east-1b",
"us-east-1c",
"us-east-1d",
"us-east-1e",
"us-east-1f"
],
"Owner": "amazon",
"BaseEndpointDnsNames": [
"s3.us-east-1.vpce.amazonaws.com"
],
"VpcEndpointPolicySupported": true,
"AcceptanceRequired": false,
"ManagesVpcEndpoints": false,
"Tags": []
}, |
❗ See better solution below Workaround for now is to tag the service endpoint: aws ec2 create-tags --resources vpce-svc-***** --tag Key=type,Value=gateway --region us-east-1 Then in terraform data "aws_vpc_endpoint_service" "s3" {
count = var.create_vpc && var.enable_s3_endpoint ? 1 : 0
service = "s3"
filter {
name = "tag:type"
values = ["gateway"]
}
} |
And here's a crufty script to tag the existing s3 gateway service endpoints in multiple regions, should you need to
|
Using AWS provider version 3.24.1 and with the solution above still getting the same error. Update: |
Thanks a lot, it worked here with some changes. We have just created the filter and changed the count assignment a little bit.
|
Guys, I got another workaround for this issue. I removed the data section and integrated with endpoint resource. resource "aws_vpc_endpoint" "s3" {
count = "${var.create_vpc && var.enable_s3_endpoint ? 1 : 0}"
vpc_id = "XXXX"
service_name = "com.amazonaws.${var.aws_region}.s3"
vpc_endpoint_type = "Gateway"
tags {
Name = "XXXXX"
}
} |
Fantastic 🎉 , confirmed this is supported with provider Here's how we implemented data "aws_region" "current" {}
resource "aws_vpc_endpoint" "s3" {
count = var.create_vpc && var.enable_s3_endpoint ? 1 : 0
vpc_id = local.vpc_id
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
vpc_endpoint_type = var.s3_vpc_endpoint_type # default = "Gateway"
tags = local.vpce_tags
} |
Error: "service_type": this field cannot be set on .terraform/modules/iq_networking/main.tf line 323, in data "aws_vpc_endpoint_service" "s3": Other details
|
Could some one help me here to solve this issue |
@fazalmasood This is because you are using provider version
|
Verified on Terraform version 0.11:
|
We are using the workaround provided by @circa10a and this has resolved the issue for us. Hopefully terraform-aws-modules/terraform-aws-vpc#587 get's accepted soon. |
What AWS Provider version are you using? I'm still getting the same error (shown below), even when using the region. |
have you removed the data block?
|
@kjsingh That may have been it. I've just removed that data block and ran plan with no errors. Still need to do some other testing but this is looking much better than it did a few hours ago. |
Thanks this worked 👍 |
Update: AWS added a new data "aws_vpc_endpoint_service" "s3" {
count = var.create_vpc && var.enable_s3_endpoint ? 1 : 0
service = "s3"
filter {
name = "service-type"
values = ["Gateway"]
}
} This is new API functionality that will work with any client, independent of terraform/provider versions |
…rom client-side to API Reference: #17417 Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccDataSourceAwsVpcEndpointService_interface (12.25s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Interface (12.65s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Gateway (12.65s) --- PASS: TestAccDataSourceAwsVpcEndpointService_gateway (12.65s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom (217.41s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter (219.87s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter_tags (228.91s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccDataSourceAwsVpcEndpointService_gateway (16.05s) --- PASS: TestAccDataSourceAwsVpcEndpointService_interface (16.25s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Interface (16.26s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Gateway (16.26s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter_tags (229.07s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom (229.30s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter (229.52s) ```
FYI that v2.74.0 of the terraform-aws-vpc module was updated the be compatible with v2 and v3 of the terraform AWS provider. |
Hi all, we fixed this in the interim with a custom bash script (https://github.com/MysticalMount/aws_vpc_endpoint_service) - forgive me for lack of knowledge but it looks like the v2.74.0 vpc module mentioned above might be a more appropriate fix - will this automatically install along with the AWS provider in version 11 of Terraform now or are there some other steps - does this module form part of the AWS provider itself? |
…rom client-side to API (#17641) * data-soruce/aws_vpc_endpoint_service: Switch service_type filtering from client-side to API Reference: #17417 Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccDataSourceAwsVpcEndpointService_interface (12.25s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Interface (12.65s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Gateway (12.65s) --- PASS: TestAccDataSourceAwsVpcEndpointService_gateway (12.65s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom (217.41s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter (219.87s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter_tags (228.91s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccDataSourceAwsVpcEndpointService_gateway (16.05s) --- PASS: TestAccDataSourceAwsVpcEndpointService_interface (16.25s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Interface (16.26s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Gateway (16.26s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter_tags (229.07s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom (229.30s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter (229.52s) ``` * Update CHANGELOG for #17641 * data-source/aws_vpc_endpoint_service: Validate service_type argument, update CHANGELOG for #17641 Reference: #17419 Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccDataSourceAwsVpcEndpointService_interface (21.03s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Interface (22.39s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Gateway (22.48s) --- PASS: TestAccDataSourceAwsVpcEndpointService_gateway (23.76s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter (230.43s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter_tags (235.33s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom (238.79s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccDataSourceAwsVpcEndpointService_interface (30.12s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Interface (30.15s) --- PASS: TestAccDataSourceAwsVpcEndpointService_gateway (30.16s) --- PASS: TestAccDataSourceAwsVpcEndpointService_ServiceType_Gateway (30.16s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter_tags (249.96s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom (259.01s) --- PASS: TestAccDataSourceAwsVpcEndpointService_custom_filter (261.24s) ```
This fixes an issue with some of the gateway endpoints; see the upstream issue hashicorp/terraform-provider-aws#17417
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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. |
Problem
For those users who are encountering the following error when using the
aws_vpc_endpoint_service
data source:Error: multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service
aws_vpc_endpoint_service
) return an error if multiple results are returned.Configuration changes required to resolve the issue
Add a
filter
block to select a service type, e.g.For provider versions
v3.10.0
and up, it is also possible to use theservice_type
argument for simplifying the configuration:Please note that if you are using a Terraform module that relies on this datasource, the module itself will need to be updated. Terraform modules are not maintained by HashiCorp, so you will need to reach out to the modules maintainers to make that configuration update.
References
The text was updated successfully, but these errors were encountered: