resolve-ec2-id
Links
Introduction
This is a simple command-line tool which looks up the EC2 instance ID given an instance name:
$ resolve-ec2-id my-named-instance
i-1234567890abcdef0
Currently this tool only works with default credentials. Consider configuring them with environment variables or using a program like aws-vault.
Alternatives
This package is perhaps not so useful because very similar functionality can be accomplished with AWS CLI as follows:
aws ec2 describe-instances --filters 'Name=tag:Name,Values=my-named-instance' --query 'Reservations[*].Instances[*].{Instance:InstanceId}' --output text
However, this tool has slightly better error-handling; the above AWS CLI command will not generate an error in the case that no instance is found.
Installation
In order to install in a clean and isolated Python environment, it is recommended to use pipx:
pipx install resolve-ec2-id
Examples
Assuming you are using the Bash shell, to start an instance if you know the name but not the ID:
$ aws ec2 start-instances --output=yaml --instance-ids="$(resolve-ec2-id my-named-instance)"
StartingInstances:
- CurrentState:
Code: 0
Name: pending
InstanceId: i-1234567890abcdef0
PreviousState:
Code: 80
Name: stopped
This can also be used from within Python:
from resolve_ec2_id import resolve_ec2_id
ec2_id = resolve_ec2_id('my-named-instance')
Requirements
Beyond the base dependencies which install automatically, this requires either AWS CLI or boto3. (I did not make boto3 a dependency because it isn't needed if AWS CLI is already installed.)
Metadata
Release files for resolve-ec2-id 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| resolve-ec2-id-1.0.1.tar.gz | 5.0 kB | Without provenance | Details for resolve-ec2-id-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| resolve_ec2_id-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for resolve_ec2_id-1.0.1-py3-none-any.whl |
Total release size: 10.3 kB
Release files / resolve-ec2-id-1.0.1.tar.gz
| Download URL | resolve-ec2-id-1.0.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6a3d04a071e07442fa8bd82382813caa6a37ae758ee3ca042bee71bfe9c5fae
|
|
BLAKE2b-256 checksum How to use checksums |
9acc9d9c812b678687c4dcb1ed1e242340a1ba97bf29fb356e95e50e4c734682
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1029-azure
|
Release files / resolve_ec2_id-1.0.1-py3-none-any.whl
| Download URL | resolve_ec2_id-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3bedb4dc5710c4739d81a777ebff10e8a59de0bb45862ffca72c5ff5bfab0f5f
|
|
BLAKE2b-256 checksum How to use checksums |
4d3f760ae2a8486ed8de8b6fc0cf3821d72fe5d286f6d616f90743490bda271c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1029-azure
|
Security for resolve-ec2-id 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.