Since yesterday, I've been getting an Access Denied error when I'm trying to upload a file to one of my S3 buckets.
Javascript code:
var pass = new stream.PassThrough();
var contentType = (input.fileName.endsWith('.html') ? 'text/html' : 'text/javascript');
var params = {
Bucket: 'BUCKET_NAME',
Key: input.fileName,
Body: pass,
ACL: 'public-read',
ContentType: contentType
};
S3.upload(params, function(err, data) {
if (err) {
console.error('Error while uploading file: ' + err + '. Uploading file ' + params.Key + ' to Bucket ' + params.Bucket + '.');
throw err
}
});
return pass;
My initial thought was that this was because of the IAM policies, although I hadn't changed anything and it worked previously.
IAM policy:
{
"Action": [
"s3:PutObject",
"s3:PubObjectACL"
],
"Resource": [
"arn:aws:s3:::BUCKET_NAME/*"
],
"Effect": "Allow"
}
I've been staring at this for the past few hours, but I can't really see what the problem is. According to this link, it should be the correct way to configure the policies. And yesterday this worked fine.
edit> I just tried with "Action" : "*" and I get the same result.
This is embarrassing ...
Didn't read the Policy properly, PubObjectACL is not the correct name, PutObjectACL is.