Created
August 30, 2018 00:55
-
-
Save tecmaverick/26e015f4b104ae4a1de72b1d53e54d82 to your computer and use it in GitHub Desktop.
View and delete ENIs created by lambda in "available" status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Specify the region you want to run your scripts | |
region_val="ap-southeast-2" | |
#View Lambda function name asscoiated with ENIs in *in-use* status in a specific AWS region | |
aws ec2 describe-network-interfaces \ | |
--filters "Name=description,Values='AWS Lambda VPC ENI*'" "Name=status,Values='in-use'" \ | |
--query "NetworkInterfaces[].[RequesterId,Status,NetworkInterfaceId]" \ | |
--output text --region $region_val | |
#View Lambda function name asscoiated with ENIs in *available* status in a specific AWS region | |
aws ec2 describe-network-interfaces \ | |
--filters "Name=description,Values='AWS Lambda VPC ENI*'" "Name=status,Values='available'" \ | |
--query "NetworkInterfaces[].[RequesterId,Status,NetworkInterfaceId]" \ | |
--output text --region $region_val | |
#Deletes ENIs in *available* status created by lambda function(s) in the specific AWS region | |
aws ec2 describe-network-interfaces \ | |
--filters "Name=description,Values='AWS Lambda VPC ENI*'" "Name=status,Values='available'" \ | |
--query "NetworkInterfaces[].[NetworkInterfaceId]" \ | |
--output text \ | |
--region $region_val | \ | |
xargs -I {} \ | |
aws ec2 delete-network-interface \ | |
--network-interface-id {} \ | |
--region $region_val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment