Skip to content
Advertisement

botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL

I am using boto3 to read many text files in S3 through a Lambda Python function.

My codes for the connection to S3 below

JavaScript

About 30 text files are successfully ok. But after, it gets below error message

JavaScript

Any way I can resolve this?

Advertisement

Answer

Lambda in a VPC does not have public IP and therefor can’t access internet from public subnets. Thus you can create NAT gateway in a public subnet, and place your lambda in private subnet. Once you setup route tables for any 0.0.0.0/0 connections in the private subnet to go to the NAT, your lambda will get internet access:

Instead, you can avoid using NAT and the internet with VPC interface endpoint for AWS Config.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement