Cannot create a vpc endpoint in a region other than us-east-1

0

I have code that looks something like this:

ec2 = boto3.client("ec2", region_name='us-east-1')
endpoint = ec2.create_vpc_endpoint(
        VpcId=vpc.id,
        VpcEndpointType="Gateway",
        ServiceName=VPC_S3_ENDPOINT,
        RouteTableIds=rtb_id_list
)

The vpc referenced here has been previously created in the us-east-1 region. The create_vpc_endpoint call works fine, creating the S3 endpoint as expected in us-east-1. If I change the region though to us-east-2 for both my vpc and the create_vpc_endpoint, call, I get this error:

botocore.exceptions.ClientError: An error occurred (InvalidServiceName) when calling the CreateVpcEndpoint operation: The Vpc Endpoint Service 'com.amazonaws.us-east-1.s3' does not exist

I get a similar error when creating an endpoint for DynamoDB.

I've tried various alternatives but nothing works. What's the correct way to create a vpc endpoint in a region other than us-east-1?

preguntada hace 5 años1134 visualizaciones
1 Respuesta
0

D'oh. This definitely falls into the category of user error. I'd completely forgot that the constant VPC_S3_ENDPOINT was one of my own creation, part of my original project from several months ago. It was set to

com.amazonaws.us-east-1.s3

and that of course is why I was getting the region error.
I'll change my constant definition to

VPC_S3_ENDPOINT = "com.amazonaws.{}.s3"

and inject the region into this constant before making the api call.

Edited by: pwsteele on Jan 4, 2019 1:13 PM

respondido hace 5 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas