aws/aws-secretsmanager-jdbc

Allow means to specify AWS profile other than `default`

DaveBender opened this issue · 1 comments

Describe the feature request
The code uses AWS's default profile, which works great when there is only one profile. But on a machine with multiple profiles, an SdkClientException with the message Unable to load AWS credentials is thrown. There doesn't appear to be a way to specify an AWS profile.

To Reproduce
Steps to reproduce the behavior:
Log into AWS multiple times with different profiles. Run code that uses the AWSSecretsManagerDriver.

Expected behavior
The code provides a way to specify the desired profile, other than default, and the driver uses the desired profile.

Additional context
Exception in thread "main" com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: You must specify a value for roleArn and roleSessionName, com.amazonaws.auth.profile.ProfileCredentialsProvider@7e985ce9: Unable to load credentials into profile [default]: AWS Access Key ID is not specified., com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@35fe2125: Failed to connect to service endpoint: ]
at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:136)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1266)
. . .

Never mind. I learned I can specify the profile in the AWS_PROFILE environmental variable.