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?

gefragt vor 5 Jahren1134 Aufrufe
1 Antwort
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

beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen