Choose profile with AWS Java sdk

787 Views Asked by At

I work on a multi env AWS project where we use Java for our Lambda functions.
Each developer has one AWS account and multiple profiles (Dev, Stg, Prod...). Using the Java SDK, We want to be able debug the Lambda functions locally using Intellij IDEA, for that, we added a main that calls the handler.
The question is, how can we globally specify the profile to use when we execute our code ?
For every execution, we are getting a not authorized access to our AWS services like Secrets Manager or S3. We figured out that it always considers the basic account and not the profile even when we specify AWS_PROFILE environment variable. Thank you very much.

1

There are 1 best solutions below

0
On

The profile is controlled globally with the AWS_PROFILE environment variable.

On the Java side you should use ProfileCredentialsProvider.