Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created April 19, 2015 14:35
Show Gist options
  • Select an option

  • Save ahoward/77e6fc002dbbb74c6bd2 to your computer and use it in GitHub Desktop.

Select an option

Save ahoward/77e6fc002dbbb74c6bd2 to your computer and use it in GitHub Desktop.
reliably construct a bucket residing in any region with ruby ruby aws-sdk v1
[a, b].each do |bucket_name|
bucket = AWS::S3.new.buckets[bucket_name]
location_constraint = bucket.location_constraint
s3_endpoint = location_constraint.blank? ? "s3.amazonaws.com" : "s3-#{ location_constraint }.amazonaws.com"
bucket = AWS::S3.new(:s3_endpoint => s3_endpoint).buckets[bucket_name]
end
# and why doesn't the API just do this? WTF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment