Skip to content

Instantly share code, notes, and snippets.

@roccoblues
Created February 25, 2021 12:14
Show Gist options
  • Save roccoblues/0b2305cf399a82b8dc0fa6e2c8e5175e to your computer and use it in GitHub Desktop.
Save roccoblues/0b2305cf399a82b8dc0fa6e2c8e5175e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'aws-sdk'
region =
access_key_id =
secret_access_key =
account_id =
accesspoint =
key = 'foo'
new_key = 'bar'
bucket_arn = "arn:aws:s3:#{region}:#{account_id}:accesspoint/#{accesspoint}"
client = Aws::S3::Client.new(
region: region,
access_key_id: access_key_id,
secret_access_key: secret_access_key
)
object = Aws::S3::Object.new(bucket_arn, key, client: client)
puts object.exists?
object.move_to(bucket: bucket_arn, key: new_key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment