aws-sdk 1.30.1 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -3
  3. data/lib/aws/api_config/CloudFront-2013-11-11.yml +2886 -0
  4. data/lib/aws/api_config/CloudTrail-2013-11-01.yml +36 -0
  5. data/lib/aws/api_config/ElasticTranscoder-2012-09-25.yml +67 -446
  6. data/lib/aws/auto_scaling.rb +0 -1
  7. data/lib/aws/auto_scaling/client.rb +2 -0
  8. data/lib/aws/cloud_formation.rb +0 -1
  9. data/lib/aws/cloud_formation/client.rb +2 -0
  10. data/lib/aws/cloud_front.rb +0 -1
  11. data/lib/aws/cloud_front/client.rb +6 -6
  12. data/lib/aws/cloud_search.rb +0 -1
  13. data/lib/aws/cloud_search/client.rb +3 -0
  14. data/lib/aws/cloud_trail.rb +0 -1
  15. data/lib/aws/cloud_trail/client.rb +2 -0
  16. data/lib/aws/cloud_watch.rb +0 -1
  17. data/lib/aws/cloud_watch/client.rb +2 -0
  18. data/lib/aws/core.rb +8 -6
  19. data/lib/aws/core/client.rb +30 -4
  20. data/lib/aws/core/configuration.rb +1 -1
  21. data/lib/aws/core/http/request.rb +2 -1
  22. data/lib/aws/core/signers/base.rb +46 -0
  23. data/lib/aws/core/signers/cloud_front.rb +56 -0
  24. data/lib/aws/core/signers/s3.rb +159 -0
  25. data/lib/aws/core/signers/version_2.rb +72 -0
  26. data/lib/aws/core/signers/version_3.rb +86 -0
  27. data/lib/aws/core/signers/version_3_https.rb +61 -0
  28. data/lib/aws/core/signers/version_4.rb +228 -0
  29. data/lib/aws/core/signers/version_4/chunk_signed_stream.rb +191 -0
  30. data/lib/aws/data_pipeline.rb +0 -1
  31. data/lib/aws/data_pipeline/client.rb +3 -0
  32. data/lib/aws/direct_connect.rb +0 -1
  33. data/lib/aws/direct_connect/client.rb +3 -0
  34. data/lib/aws/dynamo_db.rb +0 -1
  35. data/lib/aws/dynamo_db/client.rb +2 -0
  36. data/lib/aws/ec2.rb +0 -1
  37. data/lib/aws/ec2/client.rb +21 -0
  38. data/lib/aws/elastic_beanstalk.rb +0 -1
  39. data/lib/aws/elastic_beanstalk/client.rb +3 -0
  40. data/lib/aws/elastic_transcoder.rb +0 -1
  41. data/lib/aws/elastic_transcoder/client.rb +2 -0
  42. data/lib/aws/elasticache.rb +0 -1
  43. data/lib/aws/elasticache/client.rb +2 -0
  44. data/lib/aws/elb.rb +0 -1
  45. data/lib/aws/elb/client.rb +2 -0
  46. data/lib/aws/emr.rb +0 -1
  47. data/lib/aws/emr/client.rb +2 -0
  48. data/lib/aws/glacier.rb +0 -1
  49. data/lib/aws/glacier/client.rb +2 -0
  50. data/lib/aws/iam.rb +0 -1
  51. data/lib/aws/iam/client.rb +2 -0
  52. data/lib/aws/import_export.rb +0 -1
  53. data/lib/aws/import_export/client.rb +2 -0
  54. data/lib/aws/kinesis.rb +0 -1
  55. data/lib/aws/kinesis/client.rb +2 -0
  56. data/lib/aws/ops_works.rb +0 -1
  57. data/lib/aws/ops_works/client.rb +2 -0
  58. data/lib/aws/rds.rb +0 -1
  59. data/lib/aws/rds/client.rb +2 -0
  60. data/lib/aws/redshift.rb +0 -1
  61. data/lib/aws/redshift/client.rb +2 -0
  62. data/lib/aws/route_53.rb +0 -1
  63. data/lib/aws/route_53/client.rb +2 -0
  64. data/lib/aws/s3.rb +1 -0
  65. data/lib/aws/s3/bucket_collection.rb +9 -7
  66. data/lib/aws/s3/client.rb +70 -9
  67. data/lib/aws/s3/config.rb +12 -0
  68. data/lib/aws/s3/object_collection.rb +4 -9
  69. data/lib/aws/s3/presign_v4.rb +127 -0
  70. data/lib/aws/s3/presigned_post.rb +1 -1
  71. data/lib/aws/s3/request.rb +0 -136
  72. data/lib/aws/s3/s3_object.rb +40 -19
  73. data/lib/aws/simple_db.rb +0 -1
  74. data/lib/aws/simple_db/client.rb +2 -0
  75. data/lib/aws/simple_email_service.rb +0 -1
  76. data/lib/aws/simple_email_service/client.rb +2 -0
  77. data/lib/aws/simple_workflow.rb +0 -1
  78. data/lib/aws/simple_workflow/client.rb +2 -0
  79. data/lib/aws/sns.rb +0 -1
  80. data/lib/aws/sns/client.rb +2 -0
  81. data/lib/aws/sqs.rb +0 -1
  82. data/lib/aws/sqs/client.rb +2 -0
  83. data/lib/aws/storage_gateway.rb +0 -1
  84. data/lib/aws/storage_gateway/client.rb +2 -0
  85. data/lib/aws/sts.rb +0 -1
  86. data/lib/aws/sts/client.rb +2 -0
  87. data/lib/aws/support.rb +0 -1
  88. data/lib/aws/support/client.rb +2 -0
  89. data/lib/aws/version.rb +1 -1
  90. metadata +12 -38
  91. data/lib/aws/auto_scaling/request.rb +0 -29
  92. data/lib/aws/cloud_formation/request.rb +0 -29
  93. data/lib/aws/cloud_front/request.rb +0 -30
  94. data/lib/aws/cloud_search/request.rb +0 -23
  95. data/lib/aws/cloud_trail/request.rb +0 -30
  96. data/lib/aws/cloud_watch/request.rb +0 -29
  97. data/lib/aws/core/signature/version_2.rb +0 -56
  98. data/lib/aws/core/signature/version_3.rb +0 -77
  99. data/lib/aws/core/signature/version_3_https.rb +0 -54
  100. data/lib/aws/core/signature/version_4.rb +0 -135
  101. data/lib/aws/core/signer.rb +0 -46
  102. data/lib/aws/data_pipeline/request.rb +0 -26
  103. data/lib/aws/direct_connect/request.rb +0 -27
  104. data/lib/aws/dynamo_db/request.rb +0 -26
  105. data/lib/aws/ec2/request.rb +0 -21
  106. data/lib/aws/elastic_beanstalk/request.rb +0 -29
  107. data/lib/aws/elastic_transcoder/request.rb +0 -30
  108. data/lib/aws/elasticache/request.rb +0 -23
  109. data/lib/aws/elb/request.rb +0 -29
  110. data/lib/aws/emr/request.rb +0 -28
  111. data/lib/aws/glacier/request.rb +0 -29
  112. data/lib/aws/iam/request.rb +0 -29
  113. data/lib/aws/import_export/request.rb +0 -23
  114. data/lib/aws/kinesis/request.rb +0 -26
  115. data/lib/aws/ops_works/request.rb +0 -27
  116. data/lib/aws/rds/request.rb +0 -29
  117. data/lib/aws/redshift/request.rb +0 -29
  118. data/lib/aws/route_53/request.rb +0 -23
  119. data/lib/aws/simple_db/request.rb +0 -23
  120. data/lib/aws/simple_email_service/request.rb +0 -27
  121. data/lib/aws/simple_workflow/request.rb +0 -28
  122. data/lib/aws/sns/request.rb +0 -29
  123. data/lib/aws/sqs/request.rb +0 -31
  124. data/lib/aws/storage_gateway/request.rb +0 -28
  125. data/lib/aws/sts/request.rb +0 -29
  126. data/lib/aws/support/request.rb +0 -27
@@ -0,0 +1,191 @@
1
+ # Copyright 2011-2013 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 'stringio'
15
+
16
+ module AWS
17
+ module Core
18
+ module Signers
19
+ class Version4
20
+ class ChunkSignedStream
21
+
22
+ # @api private
23
+ DEFAULT_CHUNK_SIZE = 128 * 1024
24
+
25
+ # @api private
26
+ MAX_BUFFER_SIZE = 256 * 1024
27
+
28
+ # @api private
29
+ CHUNK_SIGNATURE_HEADER = ";chunk-signature="
30
+
31
+ # @api private
32
+ CHUNK_STRING_TO_SIGN_PREFIX = "AWS4-HMAC-SHA256-PAYLOAD"
33
+
34
+ # @api private
35
+ SIGNATURE_LENGTH = 64
36
+
37
+ # @api private
38
+ CLRF = "\r\n"
39
+
40
+ # @param [IO] stream The original http request body stream.
41
+ # @param [Integer] stream_size Size of the original stream in bytes.
42
+ # This must be greater than 0.
43
+ # @param [String] key The derived sigv4 signing key.
44
+ # @param [String] key_path The scope of the derived key.
45
+ # @param [String] datetime The iso8601 formatted datetime.
46
+ # @param [String] signature The computed signature of the request headers.
47
+ # @return [IO] Returns an IO-like object.
48
+ def initialize stream, stream_size, key, key_path, datetime, signature
49
+ @stream = stream || StringIO.new('')
50
+ @size = self.class.signed_size(stream_size)
51
+ @key = key
52
+ @key_path = key_path
53
+ @datetime = datetime
54
+ @prev_chunk_signature = signature
55
+ reset
56
+ end
57
+
58
+ # @return [Integer] the size of the final (signed) stream
59
+ attr_reader :size
60
+
61
+ # @param [Integer] bytes (nil)
62
+ # @param [String] output_buffer (nil)
63
+ # @return [String,nil]
64
+ def read bytes = nil, output_buffer = nil
65
+ data = read_bytes(bytes || @size)
66
+ if output_buffer
67
+ output_buffer.replace(data || '')
68
+ else
69
+ (data.nil? and bytes.nil?) ? '' : data
70
+ end
71
+ end
72
+
73
+ # @return [Integer]
74
+ def rewind
75
+ @stream.rewind
76
+ reset
77
+ end
78
+
79
+ private
80
+
81
+ def reset
82
+ @buffer = ''
83
+ @more_chunks = true
84
+ end
85
+
86
+ # @param [Integer] num_bytes The maximum number of bytes to return.
87
+ # @return [String,nil] `nil` once the complete stream has been read
88
+ def read_bytes num_bytes
89
+ fill_buffer(num_bytes)
90
+ bytes = @buffer[0,num_bytes]
91
+ @buffer = @buffer[num_bytes..-1] || '' # flatten the buffer
92
+ bytes == '' ? nil : bytes
93
+ end
94
+
95
+ # Fills the internal buffer at least +num_bytes+ of data.
96
+ # @param [Integer] num_bytes
97
+ def fill_buffer num_bytes
98
+ while @buffer.bytesize < num_bytes && more_chunks?
99
+ @buffer << next_chunk
100
+ end
101
+ end
102
+
103
+ def more_chunks?
104
+ @more_chunks
105
+ end
106
+
107
+ def next_chunk
108
+ chunk = @stream.read(DEFAULT_CHUNK_SIZE)
109
+ if chunk.nil?
110
+ chunk = ''
111
+ @more_chunks = false
112
+ end
113
+ sign_chunk(chunk)
114
+ end
115
+
116
+ # Given a chunk of the original stream, this method returns a signed
117
+ # chunk with the prefixed header.
118
+ # @param [String] chunk
119
+ # @return [String]
120
+ def sign_chunk chunk
121
+ [
122
+ chunk.bytesize.to_s(16),
123
+ CHUNK_SIGNATURE_HEADER,
124
+ next_chunk_signature(chunk),
125
+ CLRF,
126
+ chunk,
127
+ CLRF,
128
+ ].join
129
+ end
130
+
131
+ # @param [String] chunk
132
+ # @return [String]
133
+ def next_chunk_signature chunk
134
+ string_to_sign = [
135
+ "AWS4-HMAC-SHA256-PAYLOAD",
136
+ @datetime,
137
+ @key_path,
138
+ @prev_chunk_signature,
139
+ hash(''),
140
+ hash(chunk),
141
+ ].join("\n")
142
+ signature = sign(string_to_sign)
143
+ @prev_chunk_signature = signature
144
+ signature
145
+ end
146
+
147
+ def sign value
148
+ @digest ||= OpenSSL::Digest::Digest.new('sha256')
149
+ OpenSSL::HMAC.hexdigest(@digest, @key, value)
150
+ end
151
+
152
+ def hash value
153
+ Digest::SHA256.new.update(value).hexdigest
154
+ end
155
+
156
+ class << self
157
+
158
+ # Computes the final size of a chunked signed stream.
159
+ # @param [Integer] size Size of the original, unsigned stream.
160
+ # @return [Integer]
161
+ def signed_size size
162
+ full_sized_chunks = size / DEFAULT_CHUNK_SIZE
163
+ trailing_bytes = size % DEFAULT_CHUNK_SIZE
164
+ length = 0
165
+ length += full_sized_chunks * header_length(DEFAULT_CHUNK_SIZE)
166
+ length += trailing_bytes > 0 ? header_length(trailing_bytes) : 0
167
+ length += header_length(0)
168
+ length
169
+ end
170
+
171
+ private
172
+
173
+ # Computes the size of a header that prefixes a chunk. The size
174
+ # appears in the header as a string.
175
+ # @param [Integer] size
176
+ # @return [Integer]
177
+ def header_length size
178
+ size.to_s(16).length +
179
+ CHUNK_SIGNATURE_HEADER.length +
180
+ SIGNATURE_LENGTH +
181
+ CLRF.length +
182
+ size +
183
+ CLRF.length
184
+ end
185
+
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
@@ -63,7 +63,6 @@ module AWS
63
63
 
64
64
  autoload :Client, 'aws/data_pipeline/client'
65
65
  autoload :Errors, 'aws/data_pipeline/errors'
66
- autoload :Request, 'aws/data_pipeline/request'
67
66
 
68
67
  include Core::ServiceInterface
69
68
 
@@ -17,8 +17,11 @@ module AWS
17
17
  # Client class for AWS Data Pipeline.
18
18
  class Client < Core::JSONClient
19
19
 
20
+
20
21
  API_VERSION = '2012-10-29'
21
22
 
23
+ signature_version :Version4, 'datapipeline'
24
+
22
25
  # @api private
23
26
  CACHEABLE_REQUESTS = Set[]
24
27
 
@@ -64,7 +64,6 @@ module AWS
64
64
 
65
65
  autoload :Client, 'aws/direct_connect/client'
66
66
  autoload :Errors, 'aws/direct_connect/errors'
67
- autoload :Request, 'aws/direct_connect/request'
68
67
 
69
68
  include Core::ServiceInterface
70
69
 
@@ -17,8 +17,11 @@ module AWS
17
17
  # Client class for AWS Direct Connect.
18
18
  class Client < Core::JSONClient
19
19
 
20
+
20
21
  API_VERSION = '2012-10-25'
21
22
 
23
+ signature_version :Version4, 'directconnect'
24
+
22
25
  # @api private
23
26
  CACHEABLE_REQUESTS = Set[]
24
27
 
@@ -115,7 +115,6 @@ module AWS
115
115
  autoload :ItemCollection, 'aws/dynamo_db/item_collection'
116
116
  autoload :Keys, 'aws/dynamo_db/keys'
117
117
  autoload :PrimaryKeyElement, 'aws/dynamo_db/primary_key_element'
118
- autoload :Request, 'aws/dynamo_db/request'
119
118
  autoload :Resource, 'aws/dynamo_db/resource'
120
119
  autoload :Table, 'aws/dynamo_db/table'
121
120
  autoload :TableCollection, 'aws/dynamo_db/table_collection'
@@ -55,6 +55,8 @@ module AWS
55
55
 
56
56
  API_VERSION = '2011-12-05'
57
57
 
58
+ signature_version :Version4, 'dynamodb'
59
+
58
60
  # @private
59
61
  REGION_US_E1 = 'dynamodb.us-east-1.amazonaws.com'
60
62
 
@@ -258,7 +258,6 @@ module AWS
258
258
  autoload :PermissionCollection, 'aws/ec2/permission_collection'
259
259
  autoload :Region, 'aws/ec2/region'
260
260
  autoload :RegionCollection, 'aws/ec2/region_collection'
261
- autoload :Request, 'aws/ec2/request'
262
261
  autoload :ReservedInstances, 'aws/ec2/reserved_instances'
263
262
  autoload :ReservedInstancesCollection, 'aws/ec2/reserved_instances_collection'
264
263
  autoload :ReservedInstancesOffering, 'aws/ec2/reserved_instances_offering'
@@ -19,6 +19,14 @@ module AWS
19
19
 
20
20
  API_VERSION = '2013-10-15'
21
21
 
22
+ def sign_request request
23
+ if @region =~ /^cn-/
24
+ v4_signer.sign_request(request)
25
+ else
26
+ v2_signer.sign_request(request)
27
+ end
28
+ end
29
+
22
30
  # @api private
23
31
  CACHEABLE_REQUESTS = Set[
24
32
  :describe_addresses,
@@ -58,6 +66,19 @@ module AWS
58
66
  :describe_network_interface_attribute,
59
67
  ]
60
68
 
69
+ protected
70
+
71
+ # @return [Core::Signers::Version2]
72
+ def v2_signer
73
+ @v2_signer ||= Core::Signers::Version2.new(credential_provider)
74
+ end
75
+
76
+ # @return [Core::Signers::Version4]
77
+ def v4_signer
78
+ @v4_signer ||=
79
+ Core::Signers::Version4.new(credential_provider, 'ec2', @region)
80
+ end
81
+
61
82
  end
62
83
 
63
84
  class Client::V20130815 < Client
@@ -39,7 +39,6 @@ module AWS
39
39
 
40
40
  autoload :Client, 'aws/elastic_beanstalk/client'
41
41
  autoload :Errors, 'aws/elastic_beanstalk/errors'
42
- autoload :Request, 'aws/elastic_beanstalk/request'
43
42
 
44
43
  include Core::ServiceInterface
45
44
 
@@ -17,8 +17,11 @@ module AWS
17
17
  # Client class for AWS Elastic Beanstalk.
18
18
  class Client < Core::QueryClient
19
19
 
20
+
20
21
  API_VERSION = '2010-12-01'
21
22
 
23
+ signature_version :Version4, 'elasticbeanstalk'
24
+
22
25
  # @api private
23
26
  CACHEABLE_REQUESTS = Set[]
24
27
 
@@ -20,7 +20,6 @@ module AWS
20
20
 
21
21
  autoload :Client, 'aws/elastic_transcoder/client'
22
22
  autoload :Errors, 'aws/elastic_transcoder/errors'
23
- autoload :Request, 'aws/elastic_transcoder/request'
24
23
 
25
24
  include Core::ServiceInterface
26
25
 
@@ -18,6 +18,8 @@ module AWS
18
18
 
19
19
  API_VERSION = '2012-09-25'
20
20
 
21
+ signature_version :Version4, 'elastictranscoder'
22
+
21
23
  # @api private
22
24
  def extract_error_details response
23
25
  if
@@ -39,7 +39,6 @@ module AWS
39
39
 
40
40
  autoload :Client, 'aws/elasticache/client'
41
41
  autoload :Errors, 'aws/elasticache/errors'
42
- autoload :Request, 'aws/elasticache/request'
43
42
 
44
43
  include Core::ServiceInterface
45
44
 
@@ -19,6 +19,8 @@ module AWS
19
19
 
20
20
  API_VERSION = '2013-06-15'
21
21
 
22
+ signature_version :Version4, 'elasticache'
23
+
22
24
  # @api private
23
25
  CACHEABLE_REQUESTS = Set[]
24
26
 
@@ -50,7 +50,6 @@ module AWS
50
50
  autoload :LoadBalancerCollection, 'aws/elb/load_balancer_collection'
51
51
  autoload :LoadBalancerPolicy, 'aws/elb/load_balancer_policy'
52
52
  autoload :LoadBalancerPolicyCollection, 'aws/elb/load_balancer_policy_collection'
53
- autoload :Request, 'aws/elb/request'
54
53
 
55
54
  include Core::ServiceInterface
56
55
 
@@ -19,6 +19,8 @@ module AWS
19
19
 
20
20
  API_VERSION = '2012-06-01'
21
21
 
22
+ signature_version :Version4, 'elasticloadbalancing'
23
+
22
24
  # @api private
23
25
  CACHEABLE_REQUESTS = Set[]
24
26
 
@@ -71,7 +71,6 @@ module AWS
71
71
  autoload :InstanceGroupCollection, 'aws/emr/instance_group_collection'
72
72
  autoload :JobFlow, 'aws/emr/job_flow'
73
73
  autoload :JobFlowCollection, 'aws/emr/job_flow_collection'
74
- autoload :Request, 'aws/emr/request'
75
74
 
76
75
  include Core::ServiceInterface
77
76
 
@@ -19,6 +19,8 @@ module AWS
19
19
 
20
20
  API_VERSION = '2009-03-31'
21
21
 
22
+ signature_version :Version4, 'emr'
23
+
22
24
  # @api private
23
25
  CACHEABLE_REQUESTS = Set[]
24
26
 
@@ -51,7 +51,6 @@ module AWS
51
51
  autoload :ArchiveCollection, 'aws/glacier/archive_collection'
52
52
  autoload :Client, 'aws/glacier/client'
53
53
  autoload :Errors, 'aws/glacier/errors'
54
- autoload :Request, 'aws/glacier/request'
55
54
  autoload :Resource, 'aws/glacier/resource'
56
55
  autoload :Vault, 'aws/glacier/vault'
57
56
  autoload :VaultCollection, 'aws/glacier/vault_collection'
@@ -25,6 +25,8 @@ module AWS
25
25
 
26
26
  API_VERSION = '2012-06-01'
27
27
 
28
+ signature_version :Version4, 'glacier'
29
+
28
30
  # @api private
29
31
  CACHEABLE_REQUESTS = Set[]
30
32
 
@@ -151,7 +151,6 @@ module AWS
151
151
  autoload :MFADeviceCollection, 'aws/iam/mfa_device_collection'
152
152
  autoload :Policy, 'aws/iam/policy'
153
153
  autoload :PolicyCollection, 'aws/iam/policy_collection'
154
- autoload :Request, 'aws/iam/request'
155
154
  autoload :Resource, 'aws/iam/resource'
156
155
  autoload :ServerCertificate, 'aws/iam/server_certificate'
157
156
  autoload :ServerCertificateCollection, 'aws/iam/server_certificate_collection'
@@ -19,6 +19,8 @@ module AWS
19
19
 
20
20
  API_VERSION = '2010-05-08'
21
21
 
22
+ signature_version :Version4, 'iam'
23
+
22
24
  # @api private
23
25
  CACHEABLE_REQUESTS = Set[
24
26
  :get_group,
@@ -64,7 +64,6 @@ module AWS
64
64
 
65
65
  autoload :Client, 'aws/import_export/client'
66
66
  autoload :Errors, 'aws/import_export/errors'
67
- autoload :Request, 'aws/import_export/request'
68
67
 
69
68
  include Core::ServiceInterface
70
69
 
@@ -19,6 +19,8 @@ module AWS
19
19
 
20
20
  API_VERSION = '2010-06-01'
21
21
 
22
+ signature_version :Version4, 'iam'
23
+
22
24
  # @api private
23
25
  CACHEABLE_REQUESTS = Set[]
24
26