Error: Error executing "ListBuckets" on Amazon s3 using w3tc plugin for wordpress

413 Views Asked by At

I was trying to use the the W3TC plugin for Wordpress in order to use Amazon S3 as storage for my files.

Had no problem (well, after a little headscratching anyway) creating a new IAM user and getting the connection from the plugin to S3 - however when I clicked on "Test S3 Upload" it came back with the following error:

Error: Error executing "ListBuckets" on "https://s3.eu-west-2.amazonaws.com/"; AWS HTTP error: Client error: `GET https://s3.eu-west-2.amazonaws.com/` resulted in a `403 Forbidden` response: AccessDeniedAccess Denied3G27GE (truncated...) AccessDenied (client): Access Denied - AccessDeniedAccess Denied

The IAM user had the following policy attached, which is the standard policy given in pretty much all examples I could find online of how to set up a user which allows uploads to an s3 bucket:

    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:CreateBucket",
                "s3:DeleteObject",
                "s3:Put*",
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": [
                "arn:aws:s3:::com.fatpigeons.fatpigeons-object-storage",
                "arn:aws:s3:::com.fatpigeons.fatpigeons-object-storage/*"
            ]
        }
    ]
}```
1

There are 1 best solutions below

0
piersb On

It seems that the "Test S3 Upload" button was trying to search for my bucket, rather than going directly there.

Allowing the IAM user to list all of my buckets at a level above the bucket itself using the following code solved the problem:

    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:CreateBucket",
                "s3:DeleteObject",
                "s3:Put*",
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": [
                "arn:aws:s3:::com.fatpigeons.fatpigeons-object-storage",
                "arn:aws:s3:::com.fatpigeons.fatpigeons-object-storage/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        }
    ]
}```