Skip to main content

Allows querying EC2 instance metadata

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

query_ec2_metadata-0.1.3.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

query_ec2_metadata-0.1.3-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page