-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Description
Problem:
I have two AWS accounts, A and B. In my ~/.aws/credentials file, I have credentials for account B. While creating the wrapped clients to pass into S3EC, I am passing in credentials for account A. I am accessing a bucket in account A. Code:
S3Client s3Client = S3Client.builder().region(Region.EU_WEST_1)
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create("xxxx", "xxxx")
))
.build();
S3AsyncClient s3AsyncClient = S3AsyncClient.builder().region(Region.EU_WEST_1)
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create("xxxx", "xxxx")
))
.build();
S3Client s3ECClient = S3EncryptionClient.builder()
.kmsKeyId("xxxxx")
.wrappedClient(s3Client)
.wrappedAsyncClient(s3AsyncClient)
.enableLegacyUnauthenticatedModes(true)
.build();
ResponseInputStream<GetObjectResponse> inputStream = s3ECClient.getObject(
GetObjectRequest.builder()
.bucket("xxxx")
.key("xxxx").build());
This gives
software.amazon.encryption.s3.S3EncryptionClientException: User: arn:aws:iam::<ACCOUNT B USER> is not authorized to perform: kms:Decrypt on the resource associated with this ciphertext because the resource does not exist in this Region, no resource-based policies allow access, or a resource-based policy explicitly denies access
If I comment out the credentials in my ~/.aws/credentials, I get software.amazon.encryption.s3.S3EncryptionClientException: Unable to load credentials from any of the providers in the chain AwsCredentialsProviderChain
It works fine if put credentials of account A in my ~/.aws/credentials.
Solution:
Looks like S3EC is ignoring credentials passed in the wrapped clients and picking up credentials from the default credentials resolution chain. It should use credentials of the wrapped clients.
rxhea
Metadata
Metadata
Assignees
Labels
No labels