Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use IMDSv2 from AWS Java SDK

If an instance is configured for IMDSv2 then after upgrading AWS-CLI we are able to connect to IMDSv2 , but we can not connect to it from java code.

Also, we could not find any documentation regarding whether we need any specific version of AWS java SDK to support IMDSv2, OR is it supported implicitly, OR is it not supported from JAVA SDK yet.

One more point is , how to ask default provider chain to use IMDSv2 while trying to load credentials.

Please let me know

like image 817
Alok Bhandari Avatar asked Sep 16 '25 23:09

Alok Bhandari


1 Answers

Support for IMDSv2 was added in:

  • 1.11.678 of aws-java-sdk (commit 06a2180e)
  • 2.10.20 of aws-java-sdk-v2 (commit 53451414)

I believe the default chain for both versions of the SDK will attempt IMDSv2, but have not verified that.

like image 142
Jim Browne Avatar answered Sep 19 '25 19:09

Jim Browne