Policy and permission issues with s3 buckets?

If you see Access Denied, it may well be that it is indeed, denied.

I had a simliar issue recently, you need to loosen access restriction on AWS just enough to resolve it.

2 Likes

The S3 user has all access to all buckets. (Uncertain why backups work but not upload.)

Mine was working fine for ages then broke, but modifying the access rights resolved it.

Somewhere there was a change.

1 Like

I can try, but this is my current policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}

So the user should be able to do anything.

2 Likes

Tried again with this, same issue - backups work but uploads do not:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutAccountPublicAccessBlock",
                "s3:GetAccountPublicAccessBlock",
                "s3:ListAllMyBuckets",
                "s3:ListBucket",
                "s3:HeadBucket",
                "s3:GetBucketLocation"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::gauntlet-forums-backup",
                "arn:aws:s3:::gauntlet-forums-storage",
                "arn:aws:s3:::gauntlet-forums-backup/*",
                "arn:aws:s3:::gantlet-forums-storage/*"
            ]
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::*/*"
        }
    ]
}

Tried it with the policy in your post and in Setting up file and image uploads to S3 - still no dice.

Looks like a typo to me.

3 Likes

Fixed typo. No change. Still not working.

Is your uploads bucket empty? Delete it and let Discourse create the bucket. Also, make sure you follow the instructions in Setting up file and image uploads to S3.

4 Likes

Huzzah! Deleting the bucket fixed it! Thanks for that!

That’s so weird. I’ve seen that outcome a couple of times in the last few weeks. I’m not sure what’s going on with manually created buckets yet. :thinking:

3 Likes

Strange to be sure… I swapped out that highly-permissive policy for one made from the two posts referenced and things seem good now too.

1 Like

deleted the bucket from where? I have not been able to upload images on my forum too…

I had trouble getting uploads to work with digitalocean spaces yesterday, also with an error about the bucket already existing. I ran out of time before I could fully diagnose its. 'tis the season.

2 Likes

I deleted the bucket from S3 and let Discourse create it itself.

3 Likes

I think that’s because S3 changed their default permission settings.

The settings when I create it manually

The settings when Discourse creates it

4 Likes

My settings are same with the discourse permission settings, yet images won’t upload.

Inspect elements shows something like "failed to load resource

Are you sure? You should see an “Access Denied” error if the upload fails. I thinks it’s a problem with a policy or CORS configuration. According to your screenshot the bucket permissions seem correct (both checkboxes under the “Manage public access control lists (ACLs)” are unchecked) and you “failed to load resource” looks like the browser simply isn’t allowed to load the image.

I’ve updated the instructions in Setting up file and image uploads to S3. Maybe it helps you find the difference in your S3 bucket configuration.

2 Likes

FWIW, I also was seeing my backups suddenly fail after an upgrade. The key was the link from the Setting up file and image uploads to S3 link above and carefully following the section about adding an inline policy to the IAM user I was using for the backups. After I updated that, I got a successful backup.

3 Likes