aws-sdk 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/lib/aws/api_config/AutoScaling-2011-01-01.yml +6 -2
  2. data/lib/aws/api_config/{EC2-2012-04-01.yml → EC2-2012-06-01.yml} +12 -0
  3. data/lib/aws/api_config/STS-2011-06-15.yml +0 -4
  4. data/lib/aws/auto_scaling/client.rb +6 -2
  5. data/lib/aws/auto_scaling/launch_configuration.rb +8 -0
  6. data/lib/aws/auto_scaling/launch_configuration_collection.rb +14 -4
  7. data/lib/aws/auto_scaling/scaling_policy.rb +17 -0
  8. data/lib/aws/auto_scaling/scaling_policy_options.rb +2 -0
  9. data/lib/aws/core.rb +13 -11
  10. data/lib/aws/core/cacheable.rb +1 -1
  11. data/lib/aws/core/client.rb +40 -39
  12. data/lib/aws/core/configuration.rb +24 -15
  13. data/lib/aws/core/credential_providers.rb +395 -0
  14. data/lib/aws/core/http/net_http_handler.rb +1 -0
  15. data/lib/aws/core/http/request.rb +4 -4
  16. data/lib/aws/core/log_formatter.rb +2 -0
  17. data/lib/aws/core/signature/version_2.rb +18 -5
  18. data/lib/aws/core/signature/version_3.rb +10 -10
  19. data/lib/aws/core/signature/version_4.rb +13 -13
  20. data/lib/aws/core/signer.rb +46 -0
  21. data/lib/aws/dynamo_db/batch_write.rb +2 -1
  22. data/lib/aws/dynamo_db/client.rb +9 -24
  23. data/lib/aws/dynamo_db/table.rb +0 -23
  24. data/lib/aws/ec2/client.rb +19 -1
  25. data/lib/aws/ec2/image.rb +4 -4
  26. data/lib/aws/ec2/instance.rb +17 -5
  27. data/lib/aws/ec2/instance_collection.rb +16 -1
  28. data/lib/aws/errors.rb +40 -0
  29. data/lib/aws/s3/client.rb +2 -1
  30. data/lib/aws/s3/presigned_post.rb +10 -8
  31. data/lib/aws/s3/request.rb +7 -5
  32. data/lib/aws/s3/s3_object.rb +10 -9
  33. data/lib/aws/simple_email_service.rb +1 -1
  34. data/lib/aws/simple_email_service/identity_collection.rb +1 -1
  35. data/lib/aws/sts.rb +2 -6
  36. data/lib/aws/sts/client.rb +14 -17
  37. metadata +7 -9
  38. data/lib/aws/api_config/EC2-2011-12-15.yml +0 -3638
  39. data/lib/aws/core/default_signer.rb +0 -67
  40. data/lib/aws/core/session_signer.rb +0 -90
  41. data/lib/aws/core/signature/version_3_http.rb +0 -72
@@ -1,67 +0,0 @@
1
- # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- require 'base64'
15
- require 'openssl'
16
-
17
- module AWS
18
- module Core
19
-
20
- # Computes signatures using credentials that are stored in memory.
21
- class DefaultSigner
22
-
23
- # @return [String] The Access Key ID used to sign requests.
24
- attr_reader :access_key_id
25
-
26
- # @return [String] The Secret Access Key used to sign requests.
27
- attr_reader :secret_access_key
28
-
29
- # @return [String] The Session Token used to sign requests.
30
- attr_reader :session_token
31
-
32
- # @param [String] access_key_id The Access Key ID used to sign
33
- # requests.
34
- #
35
- # @param [String] secret_access_key The Secret Access Key used to
36
- # sign requests.
37
- #
38
- # @param [String] session_token The Session Token used to sign
39
- # requests. You can get credentials that include a session
40
- # token using the {STS} class.
41
- def initialize(access_key_id, secret_access_key, session_token = nil)
42
-
43
- @access_key_id = access_key_id
44
- @secret_access_key = secret_access_key
45
- @session_token = session_token
46
-
47
- raise "Missing credentials" unless access_key_id and secret_access_key
48
-
49
- end
50
-
51
- # Signs a string using the credentials stored in memory.
52
- #
53
- # @param [String] string_to_sign The string to sign.
54
- #
55
- # @param [String] digest_method The digest method to use when
56
- # computing the HMAC digest.
57
- def sign(string_to_sign, digest_method = 'sha256')
58
- Base64.encode64(
59
- OpenSSL::HMAC.digest(
60
- OpenSSL::Digest::Digest.new(digest_method),
61
- secret_access_key,
62
- string_to_sign)).strip
63
- end
64
-
65
- end
66
- end
67
- end
@@ -1,90 +0,0 @@
1
- # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- require 'aws/sts'
15
- require 'thread'
16
-
17
- module AWS
18
- module Core
19
-
20
- # @private
21
- class SessionSigner
22
-
23
- @create_mutex = Mutex.new
24
-
25
- def self.for config
26
- @create_mutex.synchronize do
27
- @session_signers ||= {}
28
- @session_signers[config.signer.access_key_id] ||= self.new(config)
29
- end
30
- end
31
-
32
- def initialize config
33
- @config = config
34
- @session_mutex = Mutex.new
35
- end
36
-
37
- def sign *args
38
- short_term_signer.sign(*args)
39
- end
40
-
41
- def access_key_id
42
- session.credentials[:access_key_id]
43
- end
44
-
45
- def secret_access_key
46
- session.credentials[:secret_access_key]
47
- end
48
-
49
- def session_token
50
- session.credentials[:session_token]
51
- end
52
-
53
- def refresh_session
54
- sts = AWS::STS.new(:config => @config, :use_ssl => true)
55
- @session_mutex.synchronize do
56
- @session = sts.new_session
57
- end
58
- end
59
-
60
- protected
61
- def get_session
62
- local_session = nil
63
- @session_mutex.synchronize do
64
- local_session = @session
65
- end
66
- local_session
67
- end
68
-
69
- protected
70
- def session
71
-
72
- session = get_session
73
-
74
- if session.nil?
75
- refresh_session
76
- session = get_session
77
- end
78
-
79
- session
80
-
81
- end
82
-
83
- protected
84
- def short_term_signer
85
- DefaultSigner.new(access_key_id, secret_access_key, session_token)
86
- end
87
-
88
- end
89
- end
90
- end
@@ -1,72 +0,0 @@
1
- # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- require 'openssl'
15
- require 'time'
16
-
17
- module AWS
18
- module Core
19
- module Signature
20
- module Version3
21
-
22
- def add_authorization!(signer)
23
-
24
- self.access_key_id = signer.access_key_id
25
-
26
- headers["x-amz-date"] ||= (headers["date"] ||= Time.now.rfc822)
27
- headers["host"] ||= host
28
-
29
- headers["x-amz-security-token"] = signer.session_token if
30
- signer.respond_to?(:session_token) and signer.session_token
31
-
32
- # compute the authorization
33
- request_hash = OpenSSL::Digest::SHA256.digest(string_to_sign)
34
- signature = signer.sign(request_hash)
35
- headers["x-amzn-authorization"] =
36
- "AWS3 "+
37
- "AWSAccessKeyId=#{signer.access_key_id},"+
38
- "Algorithm=HmacSHA256,"+
39
- "SignedHeaders=#{headers_to_sign.join(';')},"+
40
- "Signature=#{signature}"
41
- end
42
-
43
- protected
44
-
45
- def string_to_sign
46
- [
47
- http_method,
48
- "/",
49
- "",
50
- canonical_headers,
51
- body
52
- ].join("\n")
53
- end
54
-
55
- def canonical_headers
56
- headers_to_sign.map do |name|
57
- value = headers[name]
58
- "#{name.downcase.strip}:#{value.strip}\n"
59
- end.sort.join
60
- end
61
-
62
- def headers_to_sign
63
- headers.keys.select do |header|
64
- header == "host" ||
65
- header =~ /^x-amz/
66
- end
67
- end
68
-
69
- end
70
- end
71
- end
72
- end