Migrate from requests to urllib3 for HTTP requests.
This change reduces the number of dependencies and per-request overhead.
As a consequence, the
EC2Metadataclass no longer accepts arequests.Sessionobject, but aurllib3.PoolManager.Add a CLI for command line access to metadata values. For example, to output the current instance ID:
$ imds get instance-id i-123456
Read more in the documentation.
Drop Python 3.9 support.
Add
NetworkInterface.ipv6_prefixattribute.Thanks to Matthew Beaumont in PR #572.
- Support Python 3.14.
Add
public_keysattribute andPublicKeyclass.Thanks to Adam Novak in PR #562.
Add
instance_life_cycleattribute.Thanks to Zeev Rotshtein for the feature request in Issue #440.
Drop Python 3.8 support.
Support Python 3.13.
- Drop Python 3.7 support.
- Support Python 3.12.
- Improve type hints for the
iam_info,iam_security_credentials, andinstance_identity_documentattributes, withTypedDicts on Python 3.8+.
- Support Python 3.11.
Return
Noneforavailability_zone_idwhen the underlying endpoint returns HTTP 404.Thanks to Amir Rossert in PR #350.
- Add
autoscaling_target_lifecycle_stateattribute, as per AWS announcement.
Add
tagsattribute, a mapping of the instance tags. This requires the corresponding EC2 feature to be enabled on the instance.Thanks to Renan Rodrigues in PR #344.
Add
spot_instance_actionattribute.Thanks to Quimey Vivas in PR #346.
Add
domainandpartitionattributes.Thanks to Terry Griffin in PR #339.
Add
instance_profile_nameandiam_security_credentialsattributes.Thanks to Jean-Sebastien Jeannotte in PR #313.
- Drop Python 3.6 support.
- Support Python 3.10.
- Add
availability_zone_idattribute. - Add type hints.
- Use
functools.cached_propertyon Python 3.8+, removing the dependency on thecached-propertypackage. - Stop distributing tests to reduce package size. Tests are not intended to be run outside of the tox setup in the repository. Repackagers can use GitHub's tarballs per tag.
- Drop Python 3.5 support.
- Support Python 3.9.
- Move license from ISC to MIT License.
- Move to use Instance Metadata Service version 2. See the README for a note on its increased security and porting to lock down the less secure version 1. Thanks ThrawnCA and antuarc for the initial PR. (Issue #150)
- Update Python support to 3.5-3.8, as 3.4 has reached its end of life.
- Converted setuptools metadata to configuration file. This meant removing the
__version__attribute from the package. If you want to inspect the installed version, useimportlib.metadata.version("ec2-metadata")(docs / backport).
- Drop Python 2 support, only Python 3.4+ is supported now.
- Use timeout of 1 second for requests to the metadata API.
- Fix documentation rendering on PyPI.
- Add
interface_idtoNetworkInterface.
- Add
ipv6s,subnet_ipv6_cidr_blocks, andvpc_ipv6_cidr_blocksattributes toNetworkInterface.
- Add
instance_actionandkernel_idattributes.
- Add
iam_info,instance_profile_arnandinstance_profile_idattributes. - Refactor handling non-200 responses to be more strict for attributes where 404's are allowed.
- Fix rendering of docs on PyPI.
- All methods can now raise
requests.exceptions.HTTPErrorif the metadata API returns a bad response, rather than failing during parsing or silently returning data from non-200 responses. EC2Metadatacan now be passed arequests.Sessionobject for customization of the way requests are made.
- Make
public_*properties returnNonefor instances that aren't public.
- Add
network_interfacesattribute which is a list ofNetworkInterfaceinstances, which have many attributes themselves.
- Add
security_groupsanduser_dataattributes.
- First release on PyPI, featuring
ec2_metadataobject.