Created
September 24, 2019 14:51
-
-
Save pigri/c00ce2811a5954c89384925190827ab6 to your computer and use it in GitHub Desktop.
ENI cleaner
This file contains hidden or 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
@export ENIS=$$(aws ec2 describe-network-interfaces --filters "Name=status,Values=available" | jq ".NetworkInterfaces[] | select(.VpcId == \"$${VPC_ID}\") | .NetworkInterfaceId"); \ | |
if [[ ! -z $${DRY_RUN} ]]; then \ | |
echo "Running in dry run mode! No changes will be made. The following ENIs would be deleted:"; \ | |
echo $${ENIS}; \ | |
exit 0; \ | |
else \ | |
for eni in $$(echo $${ENIS}| tr -d "\""); \ | |
do \ | |
aws ec2 delete-network-interface --network-interface-id $${eni}; \ | |
done; \ | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment