Eugene
Eugene

Reputation: 1125

lambda timeout when calling parameter store

I have a lambda function that calls the parameter store to retrieve a credential. The code is as follows:

import boto3
ssm = boto3.client('ssm')
parameter = ssm.get_parameter(Name='credentials', WithDecryption=True)
print(parameter['Parameter']['Value'])

I have given AmazonSSMFullAccess to the lambda role. The lambda has a VPC which later I'll use it to connect to a Redshift database without public access. The inbound and outbound rules are as follows: enter image description here

There is a post AWS Lambda cannot connect to Parameter Store which mentions that if the lambda requires VPC, then add a NAT gateway.

In the lambda subnet route table: enter image description here, there seems to be already a route that goes to the internet?

But I am still getting lambda time-out errors :(

Upvotes: 4

Views: 3021

Answers (1)

Marcin
Marcin

Reputation: 239005

there seems to be already a route that goes to the internet?

Sadly, it does not. It seems you placed your lambda in a public subnet with route to internet gateway (IGW). However, you have to use private subnet with a route to NAT gateway. IGW and NAT are two different things. Have a look at this AWS guide how to make it work:

Alternatively, you can setup VPC interface endpoint for Paramter store. Then you don't need internet access for your Lambda function.

Upvotes: 4

Related Questions