Borislav Hadzhiev
Mon Sep 27 2021·2 min read
Photo by Catalin Sandru
The S3 error "(AccessDenied) when calling the PutObject operation" occurs when we try to upload a file to an S3 bucket without having the necessary permissions.
In order to solve the "(AccessDenied) when calling the PutObject operation" error:
Permissions
tab and scroll down to the
Block public access (bucket settings)
sectionacl
to public-read
, verify that creating new public ACLs is not blocked
in your bucket. Save and confirm the changes.On the same page scroll down to the Bucket Policy
section and verify that
your bucket policy does not Deny
the PutObject
action or have a
Condition
that prevents you from uploading files, e.g. an IP restriction
Verify that you are not misspelling the name of the bucket when uploading
files. E.g. in this example I try to upload a file to a bucket named hello
.
Since I don't own this bucket, I get the "(AccessDenied) when calling the
PutObject operation" error
PutObject
permissions and verify that
it has the following actions allowed:YOUR_BUCKET
placeholder with the name of your s3 bucket.{ "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:PutObject", "s3:PutObjectAcl", "s3:GetObject", "s3:GetObjectAcl", "s3:AbortMultipartUpload" ], "Resource": [ "arn:aws:s3:::YOUR_BUCKET", "arn:aws:s3:::YOUR_BUCKET/*" ], "Effect": "Allow" } ] }
Once the policy is attached to the IAM entity you will be able to upload files to your S3 bucket.