Why is ActiveStorage with S3 raising InvalidBucketName

Viewed 786

I've just added ActiveStorage to a Rails app using S3. My first use of AS on a staging env raises

Aws::S3::Errors::InvalidBucketName: The specified bucket is not valid.

The bucket already exists on S3 and ActiveStorage has the correct bucket name, region, etc. defined in storage.yml.

ActiveStorage has been given AWS IAM credentials that have full S3 access.

The bucket has been configured for CORS

<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>

Why am I getting an InvalidBucketName error? What other things should I look at?

#storage.yml
test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

amazon:
  service: S3
  access_key_id: <%= ENV.fetch('AWS_ACCESS_KEY_ID') %>
  secret_access_key: <%= ENV.fetch('AWS_SECRET_ACCESS_KEY') %>
  region: us-east-1
  bucket: <%= ENV.fetch('AWS_S3_BUCKET') %>
0 Answers
Related