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?

asked 5 years ago1128 views
1 Answer
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

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions