S3 cp AccessDenied from AWS cli with root keys
If you have environment variables AWS_SECRET_ACCESS_KEY
, AWS_ACCESS_KEY_ID
and AWS_REGION
set, AWS CLI gives higher precedence to them, and not to credentials you specify with aws configure
.
So, in my case, bash command unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
solved the problem.
Thought I would add in a very similar issue that I had where I could list buckets but could not write to a given bucket returning the error
An error occurred (AccessDenied) when calling the CreateMultipartUpload operation: Access Denied
If the bucket uses server-side encryption you'll need to add the --sse
flag to be able to write to this bucket.
https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html
Root Access keys and Secret key have full control and full privileges to interact with the AWS. Please try running the aws configure
again to recheck the setting and try again.
PS: it is highly not recommended to use root access keys - please give a thought is creating an IAM ( which take admin privileges- like root ) and use those.