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.
Asked
Active
Viewed 510 times
1

Abderrahmane Kaci Aissa
- 311
- 2
- 13
-
How are you setting your environment variable? The problem can be there. Check this docs: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default – georgeos Jun 03 '21 at 17:33
1 Answers
0
The profile is controlled globally with the AWS_PROFILE
environment variable.
On the Java side you should use ProfileCredentialsProvider
.

madhead
- 31,729
- 16
- 153
- 201