4

How to coppy files between buckets in diffrent regions in AWS S3 using ruby aws-sdk-s3 gem? Buckets are in regions: 'eu-central-1' (target_bucket) and 'eu-west-1' (source_bucket). I want to make copy of s3://source_bucket/name_base.checksum to s3://target_bucket/source_bucket/name_base.checksum

Error:

[ERROR] The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

Testing ruby code:

require 'aws-sdk-s3'

source_bucket = 'source_bucket'
target_bucket = 'target_bucket'
name_base = 'funny_name'

begin
  s3 = Aws::S3::Client.new(
    access_key_id: '***',
    secret_access_key: '***',
    region: 'eu-west-1' # I tested also 'eu-central-1'
  )

  s3.copy_object({
    bucket: "#{target_bucket}",
    copy_source: "#{source_bucket}/#{name_base}.checksum",
    key: "#{source_bucket}/#{name_base}.checksum"
  })
rescue Aws::S3::Errors::ServiceError => e
  puts "[ERROR] #{e.message}"
end

I can't find any usefull information about this use case in documentation: https://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjectUsingRuby.html https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#copy_object-instance_method

I found old thread from 2011 I hope something changed in this case: Amazon S3 region transfer?

Any news?

Daaniell
  • 41
  • 1

0 Answers0