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

China Terraform VPC endpoint issue : Unable to Create Endpoint( ec2, sqs, lambda, ecr.api, ecr.dkr ) #1121

Open
bnisarg1 opened this issue Sep 25, 2024 · 0 comments

Comments

@bnisarg1
Copy link

Description

we are trying to create VPC endpoint in china using terraform-aws-modules/vpc/aws//modules/vpc-endpoints but we are getting error as reading EC2 VPC Endpoint Services: couldn't find resource

Note: for us-east-1, eu-west-1 we are able to create but for cn-northwest-1 and cn-north-1 we are unable to create

Below is the Error details

 Error: reading EC2 VPC Endpoint Services: couldn't find resource
│
│   with module.primary_vpc.module.vpc_endpoints.module.vpc_interface_endpoints.data.aws_vpc_endpoint_service.this["lambda"],
│   on .terraform\modules\primary_vpc.vpc_endpoints.vpc_interface_endpoints\modules\vpc-endpoints\main.tf line 11, in data "aws_vpc_endpoint_service" "this":
│   11: data "aws_vpc_endpoint_service" "this" {
│
╵
╷
│ Error: reading EC2 VPC Endpoint Services: couldn't find resource
│
│   with module.primary_vpc.module.vpc_endpoints.module.vpc_interface_endpoints.data.aws_vpc_endpoint_service.this["ecr.api"],
│   on .terraform\modules\primary_vpc.vpc_endpoints.vpc_interface_endpoints\modules\vpc-endpoints\main.tf line 11, in data "aws_vpc_endpoint_service" "this":
│   11: data "aws_vpc_endpoint_service" "this" {

│ Error: reading EC2 VPC Endpoint Services: couldn't find resource
│
│   with module.primary_vpc.module.vpc_endpoints.module.vpc_interface_endpoints.data.aws_vpc_endpoint_service.this["ec2"],
│   on .terraform\modules\primary_vpc.vpc_endpoints.vpc_interface_endpoints\modules\vpc-endpoints\main.tf line 11, in data "aws_vpc_endpoint_service" "this":
│   11: data "aws_vpc_endpoint_service" "this" {

If your request is for a new feature, please use the Feature request template.

Versions

  • Module version [Required]: 5.13.0

  • Terraform version: v1.7.5

  • Provider version(s):

Reproduction Code [Required]

module "vpc_interface_endpoints" {
  source  = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
  version = "5.13.0"

  create = length(var.interface_endpoints) > 0
  vpc_id = var.vpc.vpc_id

  endpoints = {
    for service in var.interface_endpoints :
    service => {
      service             = service,
      service_type        = "Interface",
      subnet_ids          = concat(var.vpc.private_subnets),
      tags                = { Name = "${var.resource_prefix}-${service}-endpoint" },
      security_group_ids  = try([aws_security_group.endpoint_security_group[service].id], null)
      private_dns_enabled = var.enable_endpoint_private_dns
    }
  }
}
variable "endpoints" {
  description = "Configures VPC Interface Endpoints for the mentioned services."
  type        = list(string)
  default     = ["ec2", "sns", "sqs", "ecr.api", "ecr.dkr", "lambda"]

  validation {
    error_message = "Values must be any of the following: ec2, sns, sqs, ecr.api, ecr.dkr, lambda"
    condition     = alltrue([for v in var.endpoints : contains(["ec2", "sns", "sqs", "ecr.api", "ecr.dkr", "lambda"], v)])
  }
}

Steps to reproduce the behavior:

  1. terraform plan

Expected behavior

terraform plan should not return error and resources should be created once terraform apply is executed

Actual behavior

Getting following error for ec2, lambda, sqs, ecr.dkr, ecr.api

reading EC2 VPC Endpoint Services: couldn't find resource*

Terminal Output Screenshot(s)

image

Additional context

Note: for s3 and DynomoDB we didn't face issue

on evaluation we found that s3 and dynomodb are working because
s3 and dynomodb supports service name as

  1. com.amazonaws.cn-northwest-1.s3
  2. cn.com.amazonaws.cn-northwest-1.s3

Below for both service name we are getting response
image

image

image

But for ec2,sqs,ecr.dkr service name with com.amazonaws.cn-northwest-1.ec2 not supported

but with cn.com.amazonaws.cn-northwest-1.ec2 we get response as shown below
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant