Search code examples
ruby-on-railsrails-activestorage

Why is `region` field needed for active storage on S3?


Today I tried rails 5.2.0.

It generated following file template when rails newed.

# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
#   service: S3
#   access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
#   secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
#   region: us-east-1
#   bucket: your_own_bucket

Question:

  • As far as I know, there is no region in S3 service. If so, what does this parameter field region mean in the realm of Active Storage?

Solution

  • "there is no region in S3 service", that's incorrect.

    Extracted from Working with Amazon S3 Buckets, official docs.

    Amazon S3 creates buckets in a region you specify. You can choose any AWS Region that is geographically close to you to optimize latency, minimize costs, or address regulatory requirements. For example, if you reside in Europe, you might find it advantageous to create buckets in the EU (Ireland) or EU (Frankfurt) regions. For a list of Amazon S3 regions, see Regions and Endpoints in the AWS General Reference.