This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
require 'openssl' | |
bucket_name = 'bucket-name' | |
object_key = 'object-key' | |
# patch for `aws-sdk` v2 gem (needed for versions <= v2.0.33, patch will be applied shortly to master) | |
class Aws::Signers::V4 | |
def presigned_url(request, options = {}) | |
now = Time.now.utc.strftime("%Y%m%dT%H%M%SZ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = Aws::S3::Client.new(credentials: Aws::Credentials.new('akid', 'secret')) | |
encryption_client = Aws::S3::Encryption::Client.new(client: client) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shape = sqs.config.api.operation(:receive_message).output | |
shape = Seahorse::Model::Shapes::Structure.new({ | |
'members' => { | |
shape.metadata('resultWrapper') => shape.definition, | |
'ResponseMetadata' => { | |
'type' => 'structure', | |
'members' => { | |
'RequestId' => { 'type' => 'string' } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can pass client options directly to the Resource constructor, | |
# no need to construct a client yourself | |
s3 = Aws::S3::Resource.new( | |
credentials: Aws::Credentials.new('akid', 'secret'), | |
region: 'eu-west-1' | |
) | |
s3.bucket('backup').object('dir/subdir/filename.txt').upload_file(local_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple extraction from the V1 SDK for Ruby from AWS::SQS::Queue#poll. | |
# No effort was made to test this code. | |
# | |
# @example Basic Usage | |
# | |
# poller = QueuePoller.new(queue_url) | |
# poller.poll { |msg| puts msg.body} | |
# | |
# @example Customized API client | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk-v1' | |
queue = AWS::SQS.new.queues['queue-arn'] | |
topic = AWS::SNS.new.topics['topic-arn'] | |
# this will modify the queue policy to allow the topic to send messages | |
topic.subscribe(queue) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cf = Aws::CloudFront::Client.new | |
resp = cf.create_distribution( | |
distribution_config: { | |
caller_reference: Time.now.to_i.to_s, | |
aliases: { | |
quantity: 0 | |
}, | |
default_root_object: '', | |
origins: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tree | |
def initialize(name = nil, path = '') | |
@name = name | |
@path = path | |
@folders = {} | |
@files = [] | |
end | |
attr_reader :name, :path, :folders, :files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :benchmarks do | |
namespace :dynamodb do | |
task :get_item do | |
require 'benchmark' | |
require 'aws-sdk' | |
table_name = 'aws-sdk-core-benchmarks' | |
params = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
require 'openssl' | |
class DotStream | |
def initialize(size) | |
@size = size | |
@bytes_left = size | |
end |