When using Google Cloud S3 with Discourse, ensure that the service account has the Storage Legacy Bucket Owner role on the backup bucket. This role is necessary for listing and creating/deleting objects.
Additionally, the upload bucket should use fine-grained ACL instead of uniform ACL. This is because the header set during upload specifies that it is public, and uniform ACL does not support this.
When setting up Google Cloud S3, select a region that has the same name in Amazon as on Google. This is a requirement for S3 to work correctly.
If you are using the Bitnami VM one-click install from the Google Cloud marketplace, you may need to customize the environment variables to set the DISCOURSE_S3_ENDPOINT.
Troubleshooting:
If you encounter the error “The specified location constraint is not valid”, check that the region is correctly set.
If you encounter the error “Access denied”, check that the service account has the correct role on the bucket.
If you encounter the error “Invalid argument”, check that the bucket is using fine-grained ACL instead of uniform ACL.
Thanks to Jerome_Hordies and Falco for their contributions to this discussion.
Be aware that Using S3 for Google Bucket implies to only select a Region that has the same name in Amazon than on Google.
I find it silly that you need to choose from a dropdown menu with backend validation (I tried messing with the API without success) instead of typing it.
This implies that you can’t use a bucket in europe for instance as the prefix on Amazon is EU and EUROPE on Google, nor can you use multi-region.
I also find it silly to have to set these options in Files Settings. I didn’t use S3 to upload files, I only use it for the backup. It is required to have a different bucket for uploads and backups but there is only one place to set the region which is in Files Settings.
I hope this saves somebody else time figuring this out.
PS: I debugged it using https://discourse.example.com/logs/
…
Failed to list backups from S3: The specified location constraint is not valid. → Region problem
…
Failed to list backups from S3: Access denied. → Storage Legacy Object Owner instead of Storage Legacy Bucket Owner
If you setup using the ENV variables as described in the OP, and set DISCOURSE_S3_ENDPOINT as recommened the DISCOURSE_S3_REGION is ignored making this a non-issue.
Thanks,
The thing is that I use the bitnami vm one click install from the Google cloud marketplace.
It is probably possible to customize the environment variables but not straightforward.
Setting the endpoint in the UI doesn’t ignore the region.
I enabled the fine grained ACL on the bucket instead of the uniform ACL because the header set during upload specifies that it is public. (I had a uniform ACL and set the all bucket to public)
I don’t have the right to update the OP but I think it should mention that in order for Google buckets to work the service account need the Storage Legacy Bucket Owner role on the backup bucket and the upload bucket needs to be use the fine grained ACL.