Skip to main content

EC2 Instance Metadata

This allows querying EC2 instance metadata.

It uses IMDSv2. Session credentials are NOT available using this.

Installation

Available on Pypi as query-ec2-metadata

pip install query-ec2-metadata

Command line tools

ec2-metadata

Usage: ec2-metadata KEY

This returns an attribute from the instance metadata.

The KEY can be any of the data values from https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html

instance-identity

Usage: instance-identity KEY

This returns an attribute from the instance identity document.

The key can be any of the data values from https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html

Python module

instance_identity_document() -> Dict[str, str]:

This returns the identity document for the instance.

instance_identity(key: str) -> str:

This returns an attribute from the instance identity document.

The key can be any of the data values from https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html

ec2_metadata(key: str) -> str:

This returns an attribute from the instance metadata.

The key can be any of the data values from https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html

Development

  • make init to set things up
  • make pytest to run unit tests
  • make test to run all tests

Remember to bump the version in pyproject.toml before merging.

Metadata

Release files for query-ec2-metadata 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for query-ec2-metadata 0.1.3
File Size Uploaded Provenance Actions
query_ec2_metadata-0.1.3.tar.gz 6.6 kB Without provenance Details for query_ec2_metadata-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for query-ec2-metadata 0.1.3
File Interpreter ABI Platform Actions
query_ec2_metadata-0.1.3-py3-none-any.whl Python 3 none any Details for query_ec2_metadata-0.1.3-py3-none-any.whl

Total release size: 13.7 kB

Release files / query_ec2_metadata-0.1.3.tar.gz

Download URL query_ec2_metadata-0.1.3.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d85a324ee78bd7fefba63617c11bb7c34aa96da548d6d13541f938deb6d3daf3
BLAKE2b-256 checksum
How to use checksums
54b8789c5c7a8fc839131501490046b9edeb7ee715651fb14ba597ba99f04099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.6.9 Linux/5.4.0-1047-aws

Release files / query_ec2_metadata-0.1.3-py3-none-any.whl

Download URL query_ec2_metadata-0.1.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71440823935ccc79f422b48459a503a69ded57f9bcea463fa42b7c6f91471bdc
BLAKE2b-256 checksum
How to use checksums
9d46ab638ff50cd08e1c55d39936415cdfd353cdc470f38ab0ad130ca4bb23f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.6.9 Linux/5.4.0-1047-aws

Security for query-ec2-metadata 0.1.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page