Skip to content

Instantly share code, notes, and snippets.

@pigri
Created September 24, 2019 14:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pigri/c00ce2811a5954c89384925190827ab6 to your computer and use it in GitHub Desktop.
Save pigri/c00ce2811a5954c89384925190827ab6 to your computer and use it in GitHub Desktop.
ENI cleaner
@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