-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AccessDenied with PutObject (yet works with CLI) #2009
Comments
Hi @kemitix, if you haven't already, can you try explicitly providing your credentials to the client using the AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY)))
.build(); It's possible the Java SDK is picking up a different set of credentials from your environment than the CLI is. |
Okay I see, it looks like the SDK is not able to load the credentials from your Can you give show us how you configured your file? Please do no post your actual credentials. Another option may be to try upgrading to V2 (https://github.com/aws/aws-sdk-java-v2) if that's an option for you, since it's much more compatible with the CLI. |
I can't use V2 as it doesn't support multi-part uploads or TransferManager yet. Here are my redacted credentials: [default]
; same as kemitix profile
aws_access_key_id = ak1
aws_secret_access_key = sk1
region = eu-west-1
[kemitix]
aws_access_key_id = ak1
aws_secret_access_key = sk1
region = eu-west-1
[other-account]
aws_access_key_id = ak2
aws_secret_access_key = sk2
region = eu-west-1
[an-assumedrole-account]
source_profile = other-account
role_arn = arn:aws:iam::123456123456:role/a-role-to-assume
region = eu-west-2 There are a few more profiles, but they all follow the same pattern. I've been trying to use the |
Do you by any chance have credentials defined via the environment variables or Java system properties that the default credentials chain may be picking up first over the credentials file? Lines 19 to 39 in ec9fd59
|
No, I have no |
Solved it. I tried using the debugger on the
So, the problem turns out that |
Seems to be a sdk support issue. Got solved by updating to aws-java-sdk-s3 1.11.1006. |
Using aws-java-sdk-s3 1.11.562
Error when using SDK to putObject, but works with CLI (i.e. I have IAM permissions, and my
~/.aws/credentials
file is properly configured)This works fine:
This causes the error below:
The text was updated successfully, but these errors were encountered: