I've the following scenario:
I have an external API what I need to call from a Lambda function. The external API has some restrictions:
- Require an API key what stick to the caller's IP address
- Only 1:1 (IP : API key) mappings allowed
Our environment:
- For stake of redundancy we have 3 private subnets in 3 availability zone connected to the internet with 3 NAT gateways.
- If I put my lambda function into those 3 subnets, it call out randomly with the 3 EIPs of the NAT gateway.
- So I need to lookup for the current subnet inside the lambda. From this information I can use the API key of the designated EIP for the external API request.
So my question:
How can I determine, in which subnet my lambda functions is currently running in?
As I checked unfortunately the context doesn't contain this information (according to the documentation) This doesn't answer the question: Find subnet of a lambda running in a vpc As it give back the configuration what contains all of the subnets and not the current one