Need to load in ~/.aws/credentials file

76 views
Skip to first unread message

brandon....@gmail.com

unread,
Aug 25, 2016, 11:23:03 AM8/25/16
to JetS3t Users
Hello,

I'm trying to figure out how to load an aws-formatted credentials file (typically located in ~/.aws/). This is the file that the aws CLI uses and as such credentials here can be automatically populated and updated as well as multiple profiles created. Is there any method that is able to load in this file into a ProviderCredentials object?

Here's an example of the file:
[profile1]
aws_access_key_id = blagasndfjk
aws_secret_access_key = blagasndfjk
aws_session_token = blagasndfjk
aws_security_token = blagasndfjk
token_expiration = 2016-08-25T15:21:52Z

[default]
aws_access_key_id = blagasndfjk
aws_secret_access_key = blagasndfjk
aws_session_token = blagasndfjk
aws_security_token = blagasndfjk
token_expiration = 2016-08-25T15:21:52Z

James Murty

unread,
Aug 26, 2016, 7:45:00 AM8/26/16
to jets3t...@googlegroups.com
Hi Brandon,

JetS3t doesn't have a way to read the AWS credentials file, but I believe these files use the standard INI file format [1] so you might be able to:
- find an INI file reader library
- use that library to parse the AWS credentials file and pull out the per-section settings you need
- feed the credential information intoJetS3t's ProviderCredentials object.

I don't have any experience with parsing INI files in Java, but ini4j [2] comes up high in Google searches. 

Or, if you are already using the AWS Java SDK library as you probably are, it seems to me you should be able to create its DefaultAWSCredentialsProviderChain class [3] to have it find and parse the AWS settings for you, then fetch the credential settings you need from that class to provide to JetS3t's equivalent.

Hope this helps,
James




--
You received this message because you are subscribed to the Google Groups "JetS3t Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jets3t-users+unsubscribe@googlegroups.com.
To post to this group, send email to jets3t...@googlegroups.com.
Visit this group at https://groups.google.com/group/jets3t-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages