AWS Developer Tools Blog

Working with Regions

The AWS SDK for Ruby (aws-sdk gem) has some cool new features that simplify working with regions.

The Ruby SDK defaults to the us-east-1 region for all services. Until recently, you had to specify the full regional endpoint for each service you connect to outside the default region. If you use multiple services outside us-east-1, this can be a pain. Your code might end up looking like this:

  ec2_endpoint: '',
  s3_endpoint: '',
  # and so on ...

Region to the Rescue

You can now set the default region for all services with a single configuration option. Services will construct their own regional endpoint from the default region. If you want to do all of your work in us-west-2, the example above would now look like this:

AWS.config(region: 'us-west-2')

You can pass the :region endpoint directly to a service interface. This is helpful if you need to connect to multiple regional endpoints for a single service.

s3_east = 'us-east-1')
s3_west = 'us-west-2')


The service specific endpoint options are all now deprecated. They will continue to be supported until removal in our next major revision of the Ruby SDK. The deprecated options are (replace svc with a service prefix like ec2, s3, etc):

  • :svc_endpoint
  • :svc_port
  • :svc_region

Here are a few examples of how to upgrade from the deprecated configuration options to the new options:

# service prefixed connection options are deprecated with AWS.config
AWS.config(s3_endpoint: 'localhost', s3_port: 8000)
s3 =

# service prefixed connection options are deprecated with clients
s3 = 'localhost', s3_port: 8000)

# this is the preferred method for setting endpoint and port
s3 = 'localhost', port: 8000)