Darth.Vader
Darth.Vader

Reputation: 6291

AWS Lambda function timing out on calling aws service

I have a lambda function which has the following logic in the handler:

    log.info("about to get caller identity..")
    caller_identity = boto3.client("sts").get_caller_identity()
    log.info(caller_identity)

When I run this lambda function, it times out with the following error:

botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL: "https://sts.amazonaws.com/"

Why is my lambda function not able to reach STS service?

Thanks!

Upvotes: 2

Views: 1027

Answers (1)

Chris Williams
Chris Williams

Reputation: 35238

This was the result of the Lambda being associated to a VPC in a private subnet with no way to communicate to the internet.

It is important that when using VPC configuration the Lambda is located in a subnet with the means to communicate with the internet such as a NAT. Without this your Lambda cannot communicate to the internet.

If you're trying to reach an AWS service you can check whether a VPC Endpoint is supported for the service to remove the need for internet connectivity.

Upvotes: 4

Related Questions