Optimize VPC Endpoints costs for development environment

0

Hello,

I recently set up 5 VPC Endpoints to avoid using NAT Gateway with my ECS tasks (2 for ECR, 1 for S3, 1 for Cloudwatch Logs and 1 for Secret Manager), each endpoint is linked to only one AZ. At the end, the VPC Endpoint Hours cost the same as the NAT Gateway.

As the documentation says "Pricing per VPC endpoint per AZ ($/hour)", could I detach my VPC Endpoint from all my subnets outside the working hours to avoid VPC Endpoint Hours costs ? Will the costs of endpoints be 0 or just decreased ?

2 Answers
1
Accepted Answer

Hello.

How about using Lambda and EventBridge to create a script that deletes a VPC endpoint after business hours?
There is no function to detach VPC endpoints, so I think you can reduce costs by deleting them outside of business hours.
Also, since there is no charge for the S3 gateway VPC endpoint, I think you only need to delete the interface endpoint.
You can create a Lambda function to delete VPC endpoints by using the "delete_vpc_endpoints" API.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/delete_vpc_endpoints.html

You can also create a VPC endpoint using the "create_vpc_endpoint" API.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/create_vpc_endpoint.html

profile picture
EXPERT
answered 13 days ago
profile picture
EXPERT
reviewed 8 days ago
profile picture
EXPERT
reviewed 13 days ago
1

Hi There

Another option would be to run your own NAT Instance on an EC2 instance and stop it when you are not using it.

https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html

profile pictureAWS
EXPERT
Matt-B
answered 13 days ago
profile picture
EXPERT
reviewed 8 days ago
profile picture
EXPERT
reviewed 13 days 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