aws-sdk-java
aws-sdk-java copied to clipboard
Support credential_source for use with IAM roles
It appears the java sdk doesn't support using credential_source to specify credentials from an EC2 instance role. Am I missing something? If it is not supported yet, is there any plan to add support to the java sdk soon? Thank you very much
https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#using-aws-iam-roles
I don't believe we support this currently. Marking as a feature request.
Just ran into this too, would be nice if it was added
@dagnir Is there something I can do to make this feature happen?
Thank you for raising this issue, and it looks like a great candidate for a community PR, which we’ll help merge in and support.
Supported in 2.5.30 https://github.com/aws/aws-sdk-java-v2/issues/1169
Here is a way to make it work. It requires patching the AWS Java SDK but for folks who really need this like I did it wasn't to hard to verify this method with Redshift JDBC Driver and assumeRole.
[default]
credential_source=Ec2InstanceMetadata
region=us-east-1
output=json
[redshift_iam]
role_arn=arn:aws:iam::xxxxxxxxxxxx:role/xxxx-data-dev-idmc-poc
region=us-east-1
source_profile=default
output=json
Attached is the patch.... fixes-assumerole-with-profile-file.patch
We don't have plans to support this in v1 before going into Maintenance Mode, so I'll go ahead and close.
credential_source
is supported in Java SDK v2, the recommendation is to migrate to v2. If you have any issue or feedback please open a new issue in the v2 repo.
Reference:
- Announcing end-of-support for AWS SDK for Java v1.x effective December 31, 2025 - blog post
This issue is now closed.
Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.