Connecting a Lambda in a VPC to an api gateway

0

Hello team, I currently have a lambda function in a vpc (it needs to talk to a vpc specific resource) that I will like to connect to an api gateway. I know that if the subnet the lambda resides in is connected to a nat gateway it will be able to communicate with the api gateway. However, I am looking for cheaper alternatives to a nat gateway? Please what other cheaper options can be explored (with links to documentations)?

3개 답변
2
수락된 답변

Hi.

For a lambda in a customer vpc, to connect to an API gateway, you do not need a NAT Gateway.

API gateway is a regional service, and it allows to communicate with lambdas in customer vpc without any problem, as API GW uses the public lambda API.

A Nat gateway is to be used if your lambda, in a private subnet, wants to communicate with some on the internet, like a rest API.

If your lambda must be in private vpc, and you need outbound/egress communication with the internet, then you have to use Nat gateway.

If your lambda needs to talk to some internal aws services, then vpc endpoints via private link is the way to go: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html

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

API-GW can connect to Lambda function inside A VPC.

But for lambda inside a private subnet inside a VPC , to access external resources you can use a NAT instanceinternet access to lambda in vpc instead of a NAT gateway if you are worried about NAT Gateway cost but do review the different between them here

You can also create a NAT Instance from a NAT AMI see this link

Also review this link on the functions execution role permissions and other aspects

HTH

AWS
jay-aws
답변함 2달 전
0

Thank you for the answers, I will connect the lambda in the vpc without to a nat gateway to the api gateway. Hopefully that works out in this use case, if not, I will explore the nat instance. Thank you

Olive
답변함 2달 전

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

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

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

관련 콘텐츠