My AWS profile in ~/.aws/credentials contains session credentials created by STS.
[default]
aws_session_token=XXX
aws_access_key_id=XXX
aws_secret_access_key=XXX
I am trying to access these credentials using the AWS SDK Java v2
Using the DefaultCredentialsProvider or ProfileCredentialsProvider finds them, but the returned object is of type AwsCredentials rather than AwsSessionCredentials which doesn't include the session token, only the access key ID and secret access key.
Is there any way to retrieve the full session credentials?
AwsCredentials is an interface.
public interface AwsCredentials {
String accessKeyId();
String secretAccessKey();
}
and its implemented by AwsBasicCredentials and AwsSessionCredentials.
Based on whether session token is set or not, proper class will be returned to you when one calls resolveCredentials() API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With