How to have static outbound IP address for API Gateway + Lambda

0

Hi, I am using a third party API for payments for which they need to whitelist our IP but we are on aws serverless that is an API of API gateway invoke the lambda function. so it return diff IPs on invocation. How to have static outbound IP address?

How to provide a static IP to the third party for whitelisting? I searched but found https://medium.com/financial-engines-techblog/aws-lambdas-with-a-static-outgoing-ip-5174a1e70245 or similar for static IP at lambda. but as per my assumption if a lambda returns static IP to API gateway, will the same IP be returned by API gateway to the calling party?

1 Answer
3

In short: The blog post you reference is the way to go forward.

But in a little more detail: There are two components here (at a networking level).

First, there is the connection to API Gateway from the API caller. When called that invokes the Lambda function and the Lambda function can return data to the caller. That traffic is between the caller IP address and the API Gateway IP address.

Second, there is the connection that the Lambda function establishes (outbound) to the third-party API. By default, Lambda functions can connect to external (Internet-hosted) services with no other configuration but as you've pointed out there is no static IP there. To have Lambda appear to come from a static IP address you need to have it connected to a VPC and use NAT Gateway as per the blog post.

profile pictureAWS
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions