Module: EC2

Defined in:
lib/EC2/images.rb,
lib/EC2.rb,
lib/EC2/version.rb,
lib/EC2/keypairs.rb,
lib/EC2/instances.rb,
lib/EC2/responses.rb,
lib/EC2/security_groups.rb,
lib/EC2/image_attributes.rb

Overview

Amazon Web Services EC2 Query API Ruby Library This library has been packaged as a Ruby Gem by Glenn Rempe ( glenn @nospam@ elasticworkbench.com ).

Source code and gem hosted on RubyForge under the Ruby License as of 12/14/2006: amazon-ec2.rubyforge.org

Defined Under Namespace

Modules: VERSION Classes: AWSAuthConnection, AuthorizeSecurityGroupIngressResponse, CreateKeyPairResponse, CreateSecurityGroupResponse, DeleteKeyPairResponse, DeleteSecurityGroupResponse, DeregisterImageResponse, DescribeImageAttributeResponse, DescribeImagesResponse, DescribeInstancesResponse, DescribeKeyPairsResponse, DescribeSecurityGroupsResponse, ModifyImageAttributeResponse, RegisterImageResponse, ResetImageAttributeResponse, Response, RevokeSecurityGroupIngressResponse, RunInstancesResponse, TerminateInstancesResponse

Constant Summary collapse

DEFAULT_HOST =

Which host FQDN will we connect to for all API calls to AWS?

'ec2.amazonaws.com'
PORTS_BY_SECURITY =

Define the ports to use for SSL(true) or Non-SSL(false) connections.

{ true => 443, false => 80 }
API_VERSION =

This is the version of the API as defined by Amazon Web Services

'2006-10-01'
RELEASE_VERSION =

This release version is passed in with each request as part of the HTTP ‘User-Agent’ header. Set this be the same value as what is stored in the lib/EC2/version.rb module constant instead. This way we keep it nice and DRY and only have to define the version number in a single place.

EC2::VERSION::STRING

Class Method Summary collapse

Class Method Details

.canonical_string(path) ⇒ Object

Builds the canonical string for signing. This strips out all ‘&’, ‘?’, and ‘=’ from the query string to be signed.

Note:  The parameters in the path passed in must already be sorted in
case-insensitive alphabetical order and must not be url encoded.


55
56
57
# File 'lib/EC2.rb', line 55

def EC2.canonical_string(path)
  buf = path.gsub(/\&|\?|=/,"")
end

.encode(aws_secret_access_key, str, urlencode = true) ⇒ Object

Encodes the given string with the aws_secret_access_key, by taking the hmac-sha1 sum, and then base64 encoding it. Optionally, it will also url encode the result of that to protect the string if it’s going to be used as a query string parameter.



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/EC2.rb', line 63

def EC2.encode(aws_secret_access_key, str, urlencode=true)
  digest = OpenSSL::Digest::Digest.new('sha1')
  b64_hmac =
    Base64.encode64(
      OpenSSL::HMAC.digest(digest, aws_secret_access_key, str)).strip
      
  if urlencode
    return CGI::escape(b64_hmac)
  else
    return b64_hmac
  end
end