Lambda function not able to send data to internet when using a VPC

0

Hi,

I have a lambda function which reads a RDS database and then sends the data to an external API. It works fine when I just use it without a VPC but when I connect it to a VPC, the external connection times out indicating that the lambda is not able to post to the external API. I have verified that the public subnet which is connected to the VPC has an internet gateway which is working fine. I am not able to figure out the cause. Any help would be appreciated. Thanks

Ruhail
질문됨 7달 전286회 조회
2개 답변
1

Lambda functions will not be able to access the internet on a public subnet. Lambda functions will never obtain a public IP address.

Your lambda functions need to be connected to private subnets.

On the private subnet you will need routes for the CIDR of 0.0.0.0/0 to a NAT gateway.

The NAT gateway will need to reside on the public subnet. Lambda will then be able to access the internet from your VPC.

https://docs.aws.amazon.com/appstream2/latest/developerguide/managing-network-internet-NAT-gateway.html

profile picture
전문가
답변함 7달 전
profile picture
전문가
검토됨 7달 전
0

In addition to the NAT Gateway option already mentioned, you can use IPv6 via an egress-only gateway if your external API supports IPv6. This capability was released recently - see https://aws.amazon.com/about-aws/whats-new/2023/10/aws-lambda-ipv6-outbound-connections-vpc/.

전문가
답변함 7달 전
profile picture
전문가
검토됨 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠