Use Overridable Ec2MetadataClient
for IMDS-backed Providers
#5876
Labels
ec2-metadata-client
feature-request
A feature should be added or improved.
p2
This is a standard priority issue
Describe the feature
Make IMDS-backed providers accept an
Ec2MetadataClient
instance which respects IMDS client configurations.Use Case
Various IMDS-backed providers like the
InstanceProfileRegionProvider
andInstanceProfileCredentialsProvider
make IMDS requests using anHttpURLConnection
via the SDK protected (@SdkProtectedApi
)software.amazon.awssdk.regions.util.HttpResourcesUtils
(def) class. This is instead of the publicEc2MetadataClient
(javadoc).In particular:
InstanceProfileRegionProvider
software.amazon.awssdk.regions.internal.util.EC2MetadataUtils
(def) class which uses theHttpResourcesUtils
class.InstanceProfileCredentialsProvider
HttpResourcesUtils
class directly.These may not respect certain IMDS client configurations (e.g. IMDS session token TTL) nor have features like IMDS session token caching + auto-refresh (some fetch a new token every time).
Switch to the
Ec2MetadataClient
to de-duplicate IMDS functionality.Proposed Solution
Add builders for all providers and have an
ec2MetataClient
function on the builder. For example:If the existing
InstanceProfile*Provider
providers shouldn't be refactored, create newEc2Metadata*Provider
classes instead and mark theInstanceProfile*Provider
classes as deprecated.Other Information
Requires #5764 to be fixed to reduce the likelihood of using stale IMDS session tokens.
Acknowledgements
AWS Java SDK version used
2.30.16
JDK version used
All
Operating System and version
All
The text was updated successfully, but these errors were encountered: