Metadata-Version: 2.1
Name: aws-eni-identifier
Version: 0.1.3
Summary: Identify to which AWS service network interface is associated
Home-page: https://github.com/fivexl/aws-eni-identifier
Author: Eremin
Author-email: haru.eaa@gmail.com
Requires-Python: >=3.9.0,<4.0.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: glom (>=23.1.1,<24.0.0)
Requires-Dist: typer[all] (>=0.7.0,<0.8.0)
Project-URL: Repository, https://github.com/fivexl/aws-eni-identifier
Description-Content-Type: text/markdown

# aws-eni-identifier
Identify to which AWS service network interface is associated

![aws-eni-identifier-cli.png](docs/aws-eni-identifier-cli.png?raw=true)

# Installation

```bash
pip install aws-eni-identifier
```

# Usage
aws-eni-identifier does not connect to AWS by itself, so you will need to load data with aws-cli

Login to aws:
```bash
aws sso login --profile my-profile
```

Use pipe:
```bash
aws ec2 describe-network-interfaces | aws-eni-identifier
```

Or save to file with aws-cli and read it:
```bash
aws ec2 describe-network-interfaces > ni.json
aws-eni-identifier -i ni.json
```

## Show extra columns
```bash
aws ec2 describe-network-interfaces | 
aws-eni-identifier \
    --add-column Attachment.Status \
    --add-column AvailabilityZone
```
![extra-columns.png](docs/extra-columns.png?raw=true)

## Filter
Find unused network interfaces:
```bash 
aws ec2 describe-network-interfaces \
    --filters "Name=status,Values=available" |
aws-eni-identifier
```
Find AWS resource by IP address (you can use public or private IP address)
```bash 
export IP='51.21.223.193';
aws ec2 describe-network-interfaces \
    --query "NetworkInterfaces[?PrivateIpAddresses[?PrivateIpAddress=='${IP}' || Association.PublicIp=='${IP}']]" | 
aws-eni-identifier
```
Determine what is using specific AWS network interface
```bash
aws ec2 describe-network-interfaces \
    --network-interface-ids eni-0068ac3f8786de59a | 
aws-eni-identifier
```

You can find more information about filters and queries in [AWS documentation](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-network-interfaces.html#options)
 

# Developing

Install the package:
```bash
poetry install
```
Run tests:
```bash
poetry run pytest
```
