Crates.io | available-enis |
lib.rs | available-enis |
version | 0.3.1 |
source | src |
created_at | 2024-01-15 02:11:08.81993 |
updated_at | 2024-02-13 00:10:03.459097 |
description | Count and optionally delete available AWS Elastic Networks |
homepage | |
repository | https://github.com/bruceadams/available-enis |
max_upload_size | |
id | 1099971 |
size | 99,817 |
Summarize the status of every AWS Elastic Network Interface, ENI. Optionally, delete every ENI with a status of "available".
This is a very narrow tool that pretty much does one thing: cleanup stray Elastic Network Interfaces that seem to fall out of a very complex terraform configuration that we build and tear down regularly.
This is very fast. The deletes all available ENIs concurrently.
available-enis -h
Count and optionally delete available AWS Elastic Networks
Usage: available-enis [OPTIONS]
Options:
-d, --delete Delete "available" ENIs
-p, --profile <PROFILE> AWS profile to use
-r, --region <REGION> AWS region to target
-h, --help Print help (see more with '--help')
-V, --version Print version
available-enis --help
Summarize the status of every AWS Elastic Network Interface,
ENI. Optionally, delete every ENI with a status of "available".
You can set the environment variable `RUST_LOG` to adjust
logging, for example `RUST_LOG=trace available-enis`
Usage: available-enis [OPTIONS]
Options:
-d, --delete
Delete "available" ENIs
-p, --profile <PROFILE>
AWS profile to use.
This overrides the standard (and complex!) AWS
profile handling.
-r, --region <REGION>
AWS region to target.
This override the standard (and complex!) AWS region
handling.
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bruceadams/available-enis/releases/latest/download/available-enis-installer.sh | sh
irm https://github.com/bruceadams/available-enis/releases/latest/download/available-enis-installer.ps1 | iex
npm install available-enis
or install and run the binary using npx
npx available-enis --help
brew install bruceadams/homebrew-utilities/available-enis
cargo binstall available-enis
File | Platform | Checksum |
---|---|---|
available-enis-aarch64-apple-darwin.tar.gz | macOS Apple Silicon | checksum |
available-enis-x86_64-apple-darwin.tar.gz | macOS Intel | checksum |
available-enis-x86_64-pc-windows-msvc.zip | Windows x64 | checksum |
available-enis-x86_64-unknown-linux-gnu.tar.gz | Linux x64 | checksum |
available-enis-x86_64-unknown-linux-musl.tar.gz | musl Linux x64 | checksum |
available-enis-x86_64-pc-windows-msvc.msi | Windows x64 | checksum |
This is a straightforward Rust
project using Cargo.
After installing Rust
(I highly recommend using Rustup),
cargo build
should just work.
I've been using the following Bash which uses the AWS CLI. This script is slow, deleting around two ENIs per second and isn't especially informative.
Writing a solid program in Rust is maybe over-engineering the problem. I enjoyed having a practical use case in front of me to write another Rust CLI. I'm pleased that the tool defaults to making no changes, simply reporting counts of ENI statuses it finds.
#!/usr/bin/env bash
set -euo pipefail
available_enis=$(
aws ec2 describe-network-interfaces |
jq -r '.NetworkInterfaces[] | select( .Status == "available" ) | .NetworkInterfaceId'
)
if [[ "$available_enis" ]]; then
echo "Found $(echo -n "$available_enis" | wc -l) available enis"
for eni in $available_enis; do
echo "$eni"
aws ec2 delete-network-interface --network-interface-id "$eni"
done
else
echo No available enis found
fi