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 個回答
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
專家
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南