lib/elasticity/aws_request.rb in elasticity-1.2.2 vs lib/elasticity/aws_request.rb in elasticity-1.2.3

- old
+ new

@@ -1,17 +1,24 @@ module Elasticity class AwsRequest - def initialize(aws_access_key_id, aws_secret_access_key) + # Supported values for options: + # :region - AWS region (e.g. us-west-1) + # :secure - true or false, default true. + def initialize(aws_access_key_id, aws_secret_access_key, options = {}) @access_key = aws_access_key_id @secret_key = aws_secret_access_key + @options = {:secure => true}.merge(options) end def aws_emr_request(params) - signed_params = sign_params(params, "GET", "elasticmapreduce.amazonaws.com", "/") - signed_request = "http://elasticmapreduce.amazonaws.com?#{signed_params}" + host = @options[:region] ? "elasticmapreduce.#{@options[:region]}.amazonaws.com" : "elasticmapreduce.amazonaws.com" + protocol = @options[:secure] ? "https" : "http" + + signed_params = sign_params(params, "GET", host, "/") + signed_request = "#{protocol}://#{host}?#{signed_params}" RestClient.get signed_request end # (Used from RightScale's right_aws gem.) # EC2, SQS, SDB and EMR requests must be signed by this guy. @@ -43,6 +50,6 @@ end end -end \ No newline at end of file +end