craftcms / aws-s3

Amazon S3 volume type for Craft CMS.
https://plugins.craftcms.com/aws-s3
MIT License
61 stars 28 forks source link

Getting "Unable to check if {filename} exists" when trying to upload to newly added volume #169

Closed petehjfd closed 12 months ago

petehjfd commented 1 year ago

Description

Our IAM policy is setup as per the readme, which is exactly how we set it up for all sites. However, on a new site we are getting an "Unable to check if {filename} exists" error in the CP when attempting to upload a file to a newly created volume.

If we create new access keys in S3 and use those instead, everything works fine. But obviously we'd rather not have to create new keys every time we create a new volume.

Not sure if this is an issue with the Craft plugin or with AWS/S3 itself to be honest.

Thanks

Additional info

kennethormandy commented 12 months ago

Hi @petehjfd,

I came across this error message too, and I believe it’s an AWS permissions error only.

Either there might be a typo in the policy, or maybe you are using different buckets for each volume.

If it’s the former, under resources, when you are adding in your bucket name:

        "Resource": [
            "arn:aws:s3:::bucketname/*",
            // …
        ]

…if you have only bucketname instead of bucketname/* (ie. all objects in the bucket), you’ll get the exact error message you were seeing. Adding the /* back fixes the issue.

If you are using different bucket for each volume (as opposed to, say, a different subfolder in the same bucket), you’d either need to update the policy each time to add the new bucket name to the list of resources.

That way, you can still use the same key and secret environment variable for every volume, but you would need to add the additional bucket to the policy each time.

This is with Craft v4.5.11, and v2.0.3 of the plugin as well.

If this wasn’t the case for you, free to reopen.