Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting AccessDenied deploying Gatsby to S3?

I'm following this guide to deploy to an S3 bucket using Gatsby.

If I run aws s3 ls mybucketname.com,

I get the single file I uploaded: 2019-02-15 15:53:58 477 favicon-16x16.png

However, if I run npm run deploy,

I get this error:

> gatsby-plugin-s3 deploy

✖ Failed.
AccessDenied: Access Denied

Here is the relevant code in my gatsby-config.js:

plugins: [
{
     resolve: `gatsby-plugin-s3`,
     options: {
         bucketName: 'mybucketname.com'
     },
 },

Here is the IAM policy attached to the user I created in AWS:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "ListObjectsInBucket",
        "Effect": "Allow",
        "Action": [
            "s3:ListBucket"
        ],
        "Resource": [
            "arn:aws:s3:::mybucketname.com"
        ]
    },
    {
        "Sid": "AllObjectActions",
        "Effect": "Allow",
        "Action": "s3:*Object",
        "Resource": [
            "arn:aws:s3:::mybucketname.com/*"
        ]
    }
]
}

Is there something else I can run to determine where this error is coming from?

like image 716
D'Arcy Rail-Ip Avatar asked Feb 15 '19 21:02

D'Arcy Rail-Ip


1 Answers

Try setting acl: null in gatsby-plugin-s3 options then run gatsby build

plugins: [
{
  resolve: `gatsby-plugin-s3`,
  options: {
    bucketName: 'mybucketname.com',
    acl: null
  }
}
like image 191
ksav Avatar answered Oct 14 '22 00:10

ksav