user1738539
user1738539

Reputation: 941

AWS configure get using aws java sdk

How can I get config values using the java SDK for an equivalent cli command like this: aws configure get s3.multipart_chunksize --profile profile1?

I don't see anything in the docs. I am using the aws s3 api, AmazonS3.

I am looking to store certain information from the config during object upload (aws s3 cp) as metadata, in case my configuration changes down the road, I know what config was used for a specific object.

Upvotes: 1

Views: 507

Answers (1)

bwest
bwest

Reputation: 9814

aws configure get pulls values from your local AWS configuration file. I would recommend storing the values that you need in environment variables instead. Then you can use them in java via System.getenv, and still use them in your CLI commands by using the ENV vars instead of pulling values from the config file. This will make your code more portable since it won't depend on having an AWS configuration file packaged with it.

If you need to access the values from both the configuration file and from code, you could write a quick script in e.g. bash to copy the values from the config and add them as ENV vars. Another option would be to use Java system properties if you want to set the values at run time.

Upvotes: 1

Related Questions