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:7574548
Created November 21, 2013 01:31
Reproduces a bug with the AWS::S3::CipherIO class.
require 'aws-sdk'
require 'openssl'
class DotStream
def initialize(size)
@size = size
@bytes_left = size
end
@trevorrowe
trevorrowe / enable logging
Created March 22, 2012 21:45
Enabling logging in the aws-sdk gem
require 'aws-sdk'
require 'logger'
# configure a logger instance that logs to standard out,
# this could be a file, standard error, etc. The logger only
# needs to respond to #log and accept a severity and a message.
AWS.config(:logger => Logger.new($stdout))
# make a request to see the request logger
ec2 = AWS::EC2.new
@trevorrowe
trevorrowe / debug handler example
Created March 22, 2012 21:34
Wrapping the aws-sdk http handler to view raw http requests and responses
# build a dummy http handler that extends the default handler
# that outputs the request body before making the request (via super)
# then check the response body
# req is a AWS::Core::Http::Request object
# resp is a AWS::Core::Http::Response object
default_handler = AWS.config.http_handler
debug_handler = AWS::Core::Http::Handler.new(default_handler) do |req,resp|
puts "REQUEST BODY: #{req.body}"
super(req,resp)
@trevorrowe
trevorrowe / Installing aws-sdk gem on EC2
Created February 20, 2012 17:58
Installing the aws-sdk gem on EC2 (using the Amazon Linux AMI)
sudo yum install -y gcc make \
libxml2 libxml2-devel libxslt libxslt-devel \
rubygems ruby-devel
sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib \
--with-xml2-include=/usr/local/include/libxml2 \
--with-xslt-lib=/usr/local/lib \
--with-xslt-include=/usr/local/include
sudo gem install aws-sdk --no-ri --no-rdoc