Best way to filter to find a Lambda function's Network interface IP address via Boto3?

0

I have a custom resource and I want the output to be the private ipv4 address of a specific lambda's elastic network interface of my choosing. I've figured out how to get this working and fetching an EC2's private ipv4 address.

Unfortunately the resources I do not have total control over so I cannot just add tags, and they get spun up and spun down a lot.

I know through the console, I can select the function and then examine a security group attached to it, and then search that security group in the EC2 Console screen under Network Interface, to find the Network interface that would attach to the lambda. But as far as I know, there's no direct filters or boto3 API calls to do this. I tried filtering on owner being Amazon but the owner of all the lambdas come under the AWS account in which they're housed in. I need that ENI IP address for a config file that deals with security/etc otherwise the lambda won't be able to communicate.

1 Answer
0

I would discourage you from doing this - not because what you're doing isn't working but more because Lamdba IP addresses might change from time to time. Instead, consider creating a small subnet in each Availability Zone that the Lambda functions use; then use that subnet range in your configuration file.

profile pictureAWS
EXPERT
answered 2 years 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