npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

available-enis

v0.3.1

Published

Count and optionally delete available AWS Elastic Networks

Downloads

1

Readme

Available AWS Elastic Network Interfaces

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.

Built in help

Terse

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

Complete

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

Installing

Install prebuilt binaries via shell script

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bruceadams/available-enis/releases/latest/download/available-enis-installer.sh | sh

Install prebuilt binaries via powershell script

irm https://github.com/bruceadams/available-enis/releases/latest/download/available-enis-installer.ps1 | iex

Install prebuilt binaries into your npm project

npm install available-enis

or install and run the binary using npx

npx available-enis --help

Install prebuilt binaries via Homebrew

brew install bruceadams/homebrew-utilities/available-enis

Install prebuilt binaries via cargo binstall

cargo binstall available-enis

Download

| 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 |

Building

This is a straightforward Rust project using Cargo. After installing Rust (I highly recommend using Rustup), cargo build should just work.

Background

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