aws-sdk-core 2.11.400 → 2.11.401
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apis/autoscaling/2011-01-01/api-2.json +15 -6
- data/apis/cloudformation/2010-05-15/api-2.json +101 -6
- data/apis/codebuild/2016-10-06/api-2.json +5 -2
- data/apis/config/2014-11-12/api-2.json +780 -7
- data/apis/ec2/2016-11-15/api-2.json +94 -1
- data/apis/elasticloadbalancingv2/2015-12-01/api-2.json +49 -5
- data/apis/iam/2010-05-08/api-2.json +11 -2
- data/apis/iam/2010-05-08/examples-1.json +5 -0
- data/apis/iot/2015-05-28/api-2.json +326 -7
- data/apis/lambda/2015-03-31/api-2.json +3 -0
- data/endpoints.json +8 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +102 -8
- data/lib/aws-sdk-core/version.rb +1 -1
- metadata +2 -2
@@ -2061,10 +2061,13 @@
|
|
2061
2061
|
"nodejs6.10",
|
2062
2062
|
"nodejs8.10",
|
2063
2063
|
"nodejs10.x",
|
2064
|
+
"nodejs12.x",
|
2064
2065
|
"java8",
|
2066
|
+
"java11",
|
2065
2067
|
"python2.7",
|
2066
2068
|
"python3.6",
|
2067
2069
|
"python3.7",
|
2070
|
+
"python3.8",
|
2068
2071
|
"dotnetcore1.0",
|
2069
2072
|
"dotnetcore2.0",
|
2070
2073
|
"dotnetcore2.1",
|
data/endpoints.json
CHANGED
@@ -2651,6 +2651,10 @@
|
|
2651
2651
|
"qldb" : {
|
2652
2652
|
"endpoints" : {
|
2653
2653
|
"ap-northeast-1" : { },
|
2654
|
+
"ap-northeast-2" : { },
|
2655
|
+
"ap-southeast-1" : { },
|
2656
|
+
"ap-southeast-2" : { },
|
2657
|
+
"eu-central-1" : { },
|
2654
2658
|
"eu-west-1" : { },
|
2655
2659
|
"us-east-1" : { },
|
2656
2660
|
"us-east-2" : { },
|
@@ -3326,6 +3330,10 @@
|
|
3326
3330
|
"session.qldb" : {
|
3327
3331
|
"endpoints" : {
|
3328
3332
|
"ap-northeast-1" : { },
|
3333
|
+
"ap-northeast-2" : { },
|
3334
|
+
"ap-southeast-1" : { },
|
3335
|
+
"ap-southeast-2" : { },
|
3336
|
+
"eu-central-1" : { },
|
3329
3337
|
"eu-west-1" : { },
|
3330
3338
|
"us-east-1" : { },
|
3331
3339
|
"us-east-2" : { },
|
@@ -11,6 +11,15 @@ module Aws
|
|
11
11
|
# @api private
|
12
12
|
class Non200Response < RuntimeError; end
|
13
13
|
|
14
|
+
# @api private
|
15
|
+
class TokenRetrivalError < RuntimeError; end
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
class TokenExpiredError < RuntimeError; end
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
class TokenRetrivalUnavailableError < RuntimeError; end
|
22
|
+
|
14
23
|
# These are the errors we trap when attempting to talk to the
|
15
24
|
# instance metadata service. Any of these imply the service
|
16
25
|
# is not present, no responding or some other non-recoverable
|
@@ -26,6 +35,14 @@ module Aws
|
|
26
35
|
Non200Response,
|
27
36
|
]
|
28
37
|
|
38
|
+
# Path base for GET request for profile and credentials
|
39
|
+
# @api private
|
40
|
+
METADATA_PATH_BASE = '/latest/meta-data/iam/security-credentials/'
|
41
|
+
|
42
|
+
# Path for PUT request for token
|
43
|
+
# @api private
|
44
|
+
METADATA_TOKEN_PATH = '/latest/api/token'
|
45
|
+
|
29
46
|
# @param [Hash] options
|
30
47
|
# @option options [Integer] :retries (5) Number of times to retry
|
31
48
|
# when retrieving credentials.
|
@@ -40,6 +57,8 @@ module Aws
|
|
40
57
|
# @option options [IO] :http_debug_output (nil) HTTP wire
|
41
58
|
# traces are sent to this object. You can specify something
|
42
59
|
# like $stdout.
|
60
|
+
# @option options [Integer] :token_ttl (21600) Time-to-Live in seconds for
|
61
|
+
# EC2 Metadata Token used for fetching Metadata Profile Credentials.
|
43
62
|
def initialize options = {}
|
44
63
|
@retries = options[:retries] || 5
|
45
64
|
@ip_address = options[:ip_address] || '169.254.169.254'
|
@@ -48,11 +67,13 @@ module Aws
|
|
48
67
|
@http_read_timeout = options[:http_read_timeout] || 5
|
49
68
|
@http_debug_output = options[:http_debug_output]
|
50
69
|
@backoff = backoff(options[:backoff])
|
70
|
+
@token_ttl = options[:token_ttl] || 21600
|
51
71
|
super
|
52
72
|
end
|
53
73
|
|
54
|
-
# @return [Integer]
|
55
|
-
#
|
74
|
+
# @return [Integer] Number of times to retry when retrieving credentials
|
75
|
+
# from the instance metadata service. Defaults to 0 when resolving from
|
76
|
+
# the default credential chain ({Aws::CredentialProviderChain}).
|
56
77
|
attr_reader :retries
|
57
78
|
|
58
79
|
private
|
@@ -93,9 +114,11 @@ module Aws
|
|
93
114
|
begin
|
94
115
|
retry_errors(NETWORK_ERRORS, max_retries: @retries) do
|
95
116
|
open_connection do |conn|
|
96
|
-
|
97
|
-
|
98
|
-
http_get(conn,
|
117
|
+
_token_attempt(conn)
|
118
|
+
token_value = @token.value if token_set?
|
119
|
+
profile_name = http_get(conn, METADATA_PATH_BASE, token_value)
|
120
|
+
.lines.first.strip
|
121
|
+
http_get(conn, METADATA_PATH_BASE + profile_name, token_value)
|
99
122
|
end
|
100
123
|
end
|
101
124
|
rescue
|
@@ -104,6 +127,28 @@ module Aws
|
|
104
127
|
end
|
105
128
|
end
|
106
129
|
|
130
|
+
def token_set?
|
131
|
+
@token && !@token.expired?
|
132
|
+
end
|
133
|
+
|
134
|
+
# attempt to fetch token with retries baked in
|
135
|
+
# would be skipped if token already set
|
136
|
+
def _token_attempt(conn)
|
137
|
+
begin
|
138
|
+
retry_errors(NETWORK_ERRORS, max_retries: @retries) do
|
139
|
+
unless token_set?
|
140
|
+
token_value, ttl = http_put(conn, METADATA_TOKEN_PATH, @token_ttl)
|
141
|
+
@token = Token.new(token_value, ttl) if token_value && ttl
|
142
|
+
end
|
143
|
+
end
|
144
|
+
rescue *NETWORK_ERRORS, TokenRetrivalUnavailableError
|
145
|
+
# token attempt failed with allowable errors (those indicating
|
146
|
+
# token retrieval not available on the instance), reset token to
|
147
|
+
# allow safe failover to non-token mode
|
148
|
+
@token = nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
107
152
|
def _metadata_disabled?
|
108
153
|
flag = ENV["AWS_EC2_METADATA_DISABLED"]
|
109
154
|
!flag.nil? && flag.downcase == "true"
|
@@ -118,10 +163,40 @@ module Aws
|
|
118
163
|
yield(http).tap { http.finish }
|
119
164
|
end
|
120
165
|
|
121
|
-
|
122
|
-
|
123
|
-
|
166
|
+
# GET request fetch profile and credentials
|
167
|
+
def http_get(connection, path, token=nil)
|
168
|
+
headers = {"User-Agent" => "aws-sdk-ruby2/#{VERSION}"}
|
169
|
+
headers["x-aws-ec2-metadata-token"] = token if token
|
170
|
+
response = connection.request(Net::HTTP::Get.new(path, headers))
|
171
|
+
case response.code.to_i
|
172
|
+
when 200
|
124
173
|
response.body
|
174
|
+
when 401
|
175
|
+
raise TokenExpiredError
|
176
|
+
else
|
177
|
+
raise Non200Response
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# PUT request fetch token with ttl
|
182
|
+
def http_put(connection, path, ttl)
|
183
|
+
headers = {
|
184
|
+
"User-Agent" => "aws-sdk-ruby2/#{VERSION}",
|
185
|
+
"x-aws-ec2-metadata-token-ttl-seconds" => ttl.to_s
|
186
|
+
}
|
187
|
+
response = connection.request(Net::HTTP::Put.new(path, headers))
|
188
|
+
case response.code.to_i
|
189
|
+
when 200
|
190
|
+
[
|
191
|
+
response.body,
|
192
|
+
response.header["x-aws-ec2-metadata-token-ttl-seconds"].to_i
|
193
|
+
]
|
194
|
+
when 400
|
195
|
+
raise TokenRetrivalError
|
196
|
+
when 403
|
197
|
+
when 404
|
198
|
+
when 405
|
199
|
+
raise TokenRetrivalUnavailableError
|
125
200
|
else
|
126
201
|
raise Non200Response
|
127
202
|
end
|
@@ -143,5 +218,24 @@ module Aws
|
|
143
218
|
end
|
144
219
|
end
|
145
220
|
|
221
|
+
# @api private
|
222
|
+
# Token used to fetch IMDS profile and credentials
|
223
|
+
class Token
|
224
|
+
|
225
|
+
def initialize(value, ttl)
|
226
|
+
@ttl = ttl
|
227
|
+
@value = value
|
228
|
+
@created_time = Time.now
|
229
|
+
end
|
230
|
+
|
231
|
+
# [String] token value
|
232
|
+
attr_reader :value
|
233
|
+
|
234
|
+
def expired?
|
235
|
+
Time.now - @created_time > @ttl
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|
239
|
+
|
146
240
|
end
|
147
241
|
end
|
data/lib/aws-sdk-core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.401
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jmespath
|