Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see which IP address / domain our AWS Lambda requests are being sent from..?

We're using Lambda to submit API requests to various endpoints. Lately we have been getting 403-Forbidden replies from the API endpoint(s) we're using, but it's only happening randomly.

When it pops up it seems to happen for a couple of days and then stops for awhile, but happens again later.

In order to troubleshoot this, the API provider(s) are asking me what IP address / domain we are sending requests from so that they can check their firewall.

I cannot find any report or anything showing me this, which seems unbelievable to me. I do see other threads about setting up VPC with private subnet, which would then use a static IP for all Lambda requests.

We can do that, but is there really no report or log that would show me a list of all the requests we've made and the Ip/domain it came from in the current setup?

Any information on this would be greatly appreciated. Thanks!

like image 558
Drew Angell Avatar asked Aug 31 '25 11:08

Drew Angell


1 Answers

I cannot find any report or anything showing me this, which seems unbelievable to me

Lambda exists to let you write functions without thinking about the infrastructure that it's deployed on. It seems completely reasonable to me that it doesn't give you visibility into its public IP. It may not have one.

AWS has the concept of an elastic network interface. This is an entity in the AWS software-defined network that is independent of both the physical hardware running your workload, as well as any potential public IP addresses. For example, in EC2 an ENI is associated with an instance even when it's stopped, and even though it may run on different physical hardware and get a different public IP when it's next started (I've linked to the EC2 docs because that's the best description that I know of, but the same idea applies to Lambda, ECS, and anything else on the AWS network).

If you absolutely need to know what address a particular non-VPC Lambda invocation is using, then I think your only option is to call one of the "what's my IP" APIs. However, there is no guarantee that you'll ever see the same IP address associated with one of your Lambdas in the future.

As people have noted in the comments, the best solution is to run your Lambdas in a private subnet in your VPC, with a NAT and Elastic IP to guarantee that they always appear to be using the same public IP.

like image 134
Parsifal Avatar answered Sep 03 '25 02:09

Parsifal