Skip to content

Instantly share code, notes, and snippets.

View trevorrowe's full-sized avatar

Trevor Rowe trevorrowe

  • Amazon.com
  • Seattle, WA
View GitHub Profile
@trevorrowe
trevorrowe / gist:7a36332bed24791a1196
Last active August 29, 2015 14:15
Uploading files to Amazon S3 using the AWS SDK for Ruby v2
# 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)
@trevorrowe
trevorrowe / gist:2470ceb420edb322a178
Created January 29, 2015 21:47
A simple **untested** extraction from the V1 SDK for Ruby from AWS::SQS::Queue#poll.
# 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
#
@trevorrowe
trevorrowe / gist:93c112eddc27182c9d96
Created October 15, 2014 23:34
Subscribing a queue to a topic
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)
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: {