Skip to content

sts#248

Open
albogdano wants to merge 2 commits into
davidmoten:masterfrom
albogdano:sts
Open

sts#248
albogdano wants to merge 2 commits into
davidmoten:masterfrom
albogdano:sts

Conversation

@albogdano

@albogdano albogdano commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

I think support for temporary credentials would be beneficial for the project.
Usually, in production, we never hardcode credentials in system properties or ENV. They are automatically obtained from the STS endpoint at runtime.
Additionally, this PR also adds support for obtaining credentials from instance profiles via the IMDSv2 endpoint.

With the proposed changes, the project would closely follow the default credentials discovery chain as described in the official AWS docs.

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.75362% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.47%. Comparing base (8fb9cd0) to head (92e287b).
⚠️ Report is 116 commits behind head on master.

Files with missing lines Patch % Lines
...oten/aws/lw/client/internal/CredentialsHelper.java 82.60% 2 Missing and 2 partials ⚠️
...t/internal/InstanceProfileCredentialsProvider.java 94.20% 4 Missing ⚠️
...aws/lw/client/internal/STSCredentialsProvider.java 94.44% 3 Missing and 1 partial ⚠️
...ws/lw/client/internal/ExpiringCredentialsImpl.java 93.54% 0 Missing and 2 partials ⚠️
...m/github/davidmoten/aws/lw/client/Credentials.java 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #248      +/-   ##
============================================
- Coverage     99.50%   98.47%   -1.04%     
- Complexity      479      572      +93     
============================================
  Files            31       35       +4     
  Lines          1422     1701     +279     
  Branches        168      212      +44     
============================================
+ Hits           1415     1675     +260     
- Misses            5       16      +11     
- Partials          2       10       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…endpoint, as well as from instance profiles via the IMDSv2 metadata service
return new CredentialsImpl(System.getProperty("aws.accessKeyId"),
System.getProperty("aws.secretKey"),
Optional.empty());
String sk = System.getProperty("aws.secretAccessKey");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this table, the system property aws.secretKey is outdated and is replaced with the aws.secretAccessKey in AWS SDK 2.x. This is why we check for the presence of that property and fall back to aws.secretKey.

@davidmoten

Copy link
Copy Markdown
Owner

Looks like great work, thanks! I don't use hard coded credentials by the way in my usage of this library, they are supplied by the AWS lambda environment, but nevertheless a token-based approach seems like a good idea to reduce exposure of core credentials. I'll review properly shortly.

@albogdano

Copy link
Copy Markdown
Contributor Author

Thanks, David! The STS and instance profiles methods for obtaining credentials are still heavily used in EC2 instances and for identity federation. With that addition, the credentials loading chain would be complete and on par with the official AWS SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants