aws-sdk-core 2.3.23 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 8ee5087159a2aafbd10d1f1b793557d112e5dd2645487e3600568aed96045f3a
4
- data.tar.gz: a6ebc6a591fffd3d6ff6d50b1d37dce0ae9d1fbef905ea060c6fa6e176bbf08d
2
+ SHA1:
3
+ metadata.gz: 20ae4bc1a30dde8b3aa45baeb0dd26239e7a3500
4
+ data.tar.gz: 8040c96ea9f350aa9f9daaa70e58fef875c1e085
5
5
  SHA512:
6
- metadata.gz: 6d2f75c6078b17d4a4122719e71fbf717b900da51d69074bc21c193fab6404877c92990d39cb3145dba268eb87d1a0c7d59fa0e5d2e1ad1501659de18101ed38
7
- data.tar.gz: f0c18e26582e12bf8c0effa7442991ed9b150e8d46afe9f1998c8dc8173496fdb2ce2e4fb2562ef4f5d9a9351079bf4377e56d24341902337dc304c4f7b7f553
6
+ metadata.gz: 172105f116f7c4757c1e6bd614af4e5f72e38ebe1c1462913ba79bdb0cead817ed208d6a9c6380490d4458d380ed997382864a450a2e12d08e4852ba5bb66526
7
+ data.tar.gz: 711905cc9c23291ad37891321e16071ef794edeb1918579988acd8a585ed95784edc5df016378da3c60a8fe62df350274c3bc50a70b081cff47a2ce641181dfb
@@ -40,6 +40,21 @@
40
40
  {"shape":"ServiceAccountException"}
41
41
  ]
42
42
  },
43
+ "CreateRemoteAccessSession":{
44
+ "name":"CreateRemoteAccessSession",
45
+ "http":{
46
+ "method":"POST",
47
+ "requestUri":"/"
48
+ },
49
+ "input":{"shape":"CreateRemoteAccessSessionRequest"},
50
+ "output":{"shape":"CreateRemoteAccessSessionResult"},
51
+ "errors":[
52
+ {"shape":"ArgumentException"},
53
+ {"shape":"NotFoundException"},
54
+ {"shape":"LimitExceededException"},
55
+ {"shape":"ServiceAccountException"}
56
+ ]
57
+ },
43
58
  "CreateUpload":{
44
59
  "name":"CreateUpload",
45
60
  "http":{
@@ -85,6 +100,21 @@
85
100
  {"shape":"ServiceAccountException"}
86
101
  ]
87
102
  },
103
+ "DeleteRemoteAccessSession":{
104
+ "name":"DeleteRemoteAccessSession",
105
+ "http":{
106
+ "method":"POST",
107
+ "requestUri":"/"
108
+ },
109
+ "input":{"shape":"DeleteRemoteAccessSessionRequest"},
110
+ "output":{"shape":"DeleteRemoteAccessSessionResult"},
111
+ "errors":[
112
+ {"shape":"ArgumentException"},
113
+ {"shape":"NotFoundException"},
114
+ {"shape":"LimitExceededException"},
115
+ {"shape":"ServiceAccountException"}
116
+ ]
117
+ },
88
118
  "DeleteRun":{
89
119
  "name":"DeleteRun",
90
120
  "http":{
@@ -221,6 +251,21 @@
221
251
  {"shape":"ServiceAccountException"}
222
252
  ]
223
253
  },
254
+ "GetRemoteAccessSession":{
255
+ "name":"GetRemoteAccessSession",
256
+ "http":{
257
+ "method":"POST",
258
+ "requestUri":"/"
259
+ },
260
+ "input":{"shape":"GetRemoteAccessSessionRequest"},
261
+ "output":{"shape":"GetRemoteAccessSessionResult"},
262
+ "errors":[
263
+ {"shape":"ArgumentException"},
264
+ {"shape":"NotFoundException"},
265
+ {"shape":"LimitExceededException"},
266
+ {"shape":"ServiceAccountException"}
267
+ ]
268
+ },
224
269
  "GetRun":{
225
270
  "name":"GetRun",
226
271
  "http":{
@@ -281,6 +326,21 @@
281
326
  {"shape":"ServiceAccountException"}
282
327
  ]
283
328
  },
329
+ "InstallToRemoteAccessSession":{
330
+ "name":"InstallToRemoteAccessSession",
331
+ "http":{
332
+ "method":"POST",
333
+ "requestUri":"/"
334
+ },
335
+ "input":{"shape":"InstallToRemoteAccessSessionRequest"},
336
+ "output":{"shape":"InstallToRemoteAccessSessionResult"},
337
+ "errors":[
338
+ {"shape":"ArgumentException"},
339
+ {"shape":"NotFoundException"},
340
+ {"shape":"LimitExceededException"},
341
+ {"shape":"ServiceAccountException"}
342
+ ]
343
+ },
284
344
  "ListArtifacts":{
285
345
  "name":"ListArtifacts",
286
346
  "http":{
@@ -388,6 +448,21 @@
388
448
  {"shape":"ServiceAccountException"}
389
449
  ]
390
450
  },
451
+ "ListRemoteAccessSessions":{
452
+ "name":"ListRemoteAccessSessions",
453
+ "http":{
454
+ "method":"POST",
455
+ "requestUri":"/"
456
+ },
457
+ "input":{"shape":"ListRemoteAccessSessionsRequest"},
458
+ "output":{"shape":"ListRemoteAccessSessionsResult"},
459
+ "errors":[
460
+ {"shape":"ArgumentException"},
461
+ {"shape":"NotFoundException"},
462
+ {"shape":"LimitExceededException"},
463
+ {"shape":"ServiceAccountException"}
464
+ ]
465
+ },
391
466
  "ListRuns":{
392
467
  "name":"ListRuns",
393
468
  "http":{
@@ -526,6 +601,21 @@
526
601
  {"shape":"ServiceAccountException"}
527
602
  ]
528
603
  },
604
+ "StopRemoteAccessSession":{
605
+ "name":"StopRemoteAccessSession",
606
+ "http":{
607
+ "method":"POST",
608
+ "requestUri":"/"
609
+ },
610
+ "input":{"shape":"StopRemoteAccessSessionRequest"},
611
+ "output":{"shape":"StopRemoteAccessSessionResult"},
612
+ "errors":[
613
+ {"shape":"ArgumentException"},
614
+ {"shape":"NotFoundException"},
615
+ {"shape":"LimitExceededException"},
616
+ {"shape":"ServiceAccountException"}
617
+ ]
618
+ },
529
619
  "StopRun":{
530
620
  "name":"StopRun",
531
621
  "http":{
@@ -626,6 +716,7 @@
626
716
  "SCREENSHOT",
627
717
  "DEVICE_LOG",
628
718
  "MESSAGE_LOG",
719
+ "VIDEO_LOG",
629
720
  "RESULT_LOG",
630
721
  "SERVICE_LOG",
631
722
  "WEBKIT_LOG",
@@ -718,6 +809,31 @@
718
809
  "project":{"shape":"Project"}
719
810
  }
720
811
  },
812
+ "CreateRemoteAccessSessionConfiguration":{
813
+ "type":"structure",
814
+ "members":{
815
+ "billingMethod":{"shape":"BillingMethod"}
816
+ }
817
+ },
818
+ "CreateRemoteAccessSessionRequest":{
819
+ "type":"structure",
820
+ "required":[
821
+ "projectArn",
822
+ "deviceArn"
823
+ ],
824
+ "members":{
825
+ "projectArn":{"shape":"AmazonResourceName"},
826
+ "deviceArn":{"shape":"AmazonResourceName"},
827
+ "name":{"shape":"Name"},
828
+ "configuration":{"shape":"CreateRemoteAccessSessionConfiguration"}
829
+ }
830
+ },
831
+ "CreateRemoteAccessSessionResult":{
832
+ "type":"structure",
833
+ "members":{
834
+ "remoteAccessSession":{"shape":"RemoteAccessSession"}
835
+ }
836
+ },
721
837
  "CreateUploadRequest":{
722
838
  "type":"structure",
723
839
  "required":[
@@ -767,6 +883,18 @@
767
883
  "members":{
768
884
  }
769
885
  },
886
+ "DeleteRemoteAccessSessionRequest":{
887
+ "type":"structure",
888
+ "required":["arn"],
889
+ "members":{
890
+ "arn":{"shape":"AmazonResourceName"}
891
+ }
892
+ },
893
+ "DeleteRemoteAccessSessionResult":{
894
+ "type":"structure",
895
+ "members":{
896
+ }
897
+ },
770
898
  "DeleteRunRequest":{
771
899
  "type":"structure",
772
900
  "required":["arn"],
@@ -807,7 +935,10 @@
807
935
  "memory":{"shape":"Long"},
808
936
  "image":{"shape":"String"},
809
937
  "carrier":{"shape":"String"},
810
- "radio":{"shape":"String"}
938
+ "radio":{"shape":"String"},
939
+ "remoteAccessEnabled":{"shape":"Boolean"},
940
+ "fleetType":{"shape":"String"},
941
+ "fleetName":{"shape":"String"}
811
942
  }
812
943
  },
813
944
  "DeviceAttribute":{
@@ -816,7 +947,8 @@
816
947
  "ARN",
817
948
  "PLATFORM",
818
949
  "FORM_FACTOR",
819
- "MANUFACTURER"
950
+ "MANUFACTURER",
951
+ "REMOTE_ACCESS_ENABLED"
820
952
  ]
821
953
  },
822
954
  "DeviceFormFactor":{
@@ -1003,6 +1135,19 @@
1003
1135
  "project":{"shape":"Project"}
1004
1136
  }
1005
1137
  },
1138
+ "GetRemoteAccessSessionRequest":{
1139
+ "type":"structure",
1140
+ "required":["arn"],
1141
+ "members":{
1142
+ "arn":{"shape":"AmazonResourceName"}
1143
+ }
1144
+ },
1145
+ "GetRemoteAccessSessionResult":{
1146
+ "type":"structure",
1147
+ "members":{
1148
+ "remoteAccessSession":{"shape":"RemoteAccessSession"}
1149
+ }
1150
+ },
1006
1151
  "GetRunRequest":{
1007
1152
  "type":"structure",
1008
1153
  "required":["arn"],
@@ -1073,6 +1218,23 @@
1073
1218
  "type":"list",
1074
1219
  "member":{"shape":"IncompatibilityMessage"}
1075
1220
  },
1221
+ "InstallToRemoteAccessSessionRequest":{
1222
+ "type":"structure",
1223
+ "required":[
1224
+ "remoteAccessSessionArn",
1225
+ "appArn"
1226
+ ],
1227
+ "members":{
1228
+ "remoteAccessSessionArn":{"shape":"AmazonResourceName"},
1229
+ "appArn":{"shape":"AmazonResourceName"}
1230
+ }
1231
+ },
1232
+ "InstallToRemoteAccessSessionResult":{
1233
+ "type":"structure",
1234
+ "members":{
1235
+ "appUpload":{"shape":"Upload"}
1236
+ }
1237
+ },
1076
1238
  "Integer":{"type":"integer"},
1077
1239
  "Job":{
1078
1240
  "type":"structure",
@@ -1206,6 +1368,21 @@
1206
1368
  "nextToken":{"shape":"PaginationToken"}
1207
1369
  }
1208
1370
  },
1371
+ "ListRemoteAccessSessionsRequest":{
1372
+ "type":"structure",
1373
+ "required":["arn"],
1374
+ "members":{
1375
+ "arn":{"shape":"AmazonResourceName"},
1376
+ "nextToken":{"shape":"PaginationToken"}
1377
+ }
1378
+ },
1379
+ "ListRemoteAccessSessionsResult":{
1380
+ "type":"structure",
1381
+ "members":{
1382
+ "remoteAccessSessions":{"shape":"RemoteAccessSessions"},
1383
+ "nextToken":{"shape":"PaginationToken"}
1384
+ }
1385
+ },
1209
1386
  "ListRunsRequest":{
1210
1387
  "type":"structure",
1211
1388
  "required":["arn"],
@@ -1483,6 +1660,27 @@
1483
1660
  "type":"list",
1484
1661
  "member":{"shape":"RecurringCharge"}
1485
1662
  },
1663
+ "RemoteAccessSession":{
1664
+ "type":"structure",
1665
+ "members":{
1666
+ "arn":{"shape":"AmazonResourceName"},
1667
+ "name":{"shape":"Name"},
1668
+ "created":{"shape":"DateTime"},
1669
+ "status":{"shape":"ExecutionStatus"},
1670
+ "result":{"shape":"ExecutionResult"},
1671
+ "message":{"shape":"Message"},
1672
+ "started":{"shape":"DateTime"},
1673
+ "stopped":{"shape":"DateTime"},
1674
+ "device":{"shape":"Device"},
1675
+ "billingMethod":{"shape":"BillingMethod"},
1676
+ "deviceMinutes":{"shape":"DeviceMinutes"},
1677
+ "endpoint":{"shape":"String"}
1678
+ }
1679
+ },
1680
+ "RemoteAccessSessions":{
1681
+ "type":"list",
1682
+ "member":{"shape":"RemoteAccessSession"}
1683
+ },
1486
1684
  "RenewOfferingRequest":{
1487
1685
  "type":"structure",
1488
1686
  "members":{
@@ -1634,6 +1832,19 @@
1634
1832
  },
1635
1833
  "exception":true
1636
1834
  },
1835
+ "StopRemoteAccessSessionRequest":{
1836
+ "type":"structure",
1837
+ "required":["arn"],
1838
+ "members":{
1839
+ "arn":{"shape":"AmazonResourceName"}
1840
+ }
1841
+ },
1842
+ "StopRemoteAccessSessionResult":{
1843
+ "type":"structure",
1844
+ "members":{
1845
+ "remoteAccessSession":{"shape":"RemoteAccessSession"}
1846
+ }
1847
+ },
1637
1848
  "StopRunRequest":{
1638
1849
  "type":"structure",
1639
1850
  "required":["arn"],
@@ -366,7 +366,9 @@
366
366
  {"shape":"InvalidOutputFolder"},
367
367
  {"shape":"InvalidParameters"},
368
368
  {"shape":"UnsupportedPlatformType"},
369
- {"shape":"MaxDocumentSizeExceeded"}
369
+ {"shape":"MaxDocumentSizeExceeded"},
370
+ {"shape":"InvalidRole"},
371
+ {"shape":"InvalidNotificationConfig"}
370
372
  ]
371
373
  },
372
374
  "UpdateAssociationStatus":{
@@ -597,7 +599,9 @@
597
599
  "RequestedDateTime":{"shape":"DateTime"},
598
600
  "Status":{"shape":"CommandStatus"},
599
601
  "OutputS3BucketName":{"shape":"S3BucketName"},
600
- "OutputS3KeyPrefix":{"shape":"S3KeyPrefix"}
602
+ "OutputS3KeyPrefix":{"shape":"S3KeyPrefix"},
603
+ "ServiceRole":{"shape":"ServiceRole"},
604
+ "NotificationConfig":{"shape":"NotificationConfig"}
601
605
  }
602
606
  },
603
607
  "CommandFilter":{
@@ -644,7 +648,9 @@
644
648
  "RequestedDateTime":{"shape":"DateTime"},
645
649
  "Status":{"shape":"CommandInvocationStatus"},
646
650
  "TraceOutput":{"shape":"InvocationTraceOutput"},
647
- "CommandPlugins":{"shape":"CommandPluginList"}
651
+ "CommandPlugins":{"shape":"CommandPluginList"},
652
+ "ServiceRole":{"shape":"ServiceRole"},
653
+ "NotificationConfig":{"shape":"NotificationConfig"}
648
654
  }
649
655
  },
650
656
  "CommandInvocationList":{
@@ -1346,6 +1352,13 @@
1346
1352
  },
1347
1353
  "exception":true
1348
1354
  },
1355
+ "InvalidNotificationConfig":{
1356
+ "type":"structure",
1357
+ "members":{
1358
+ "Message":{"shape":"String"}
1359
+ },
1360
+ "exception":true
1361
+ },
1349
1362
  "InvalidOutputFolder":{
1350
1363
  "type":"structure",
1351
1364
  "members":{
@@ -1378,6 +1391,13 @@
1378
1391
  },
1379
1392
  "exception":true
1380
1393
  },
1394
+ "InvalidRole":{
1395
+ "type":"structure",
1396
+ "members":{
1397
+ "Message":{"shape":"String"}
1398
+ },
1399
+ "exception":true
1400
+ },
1381
1401
  "InvocationTraceOutput":{
1382
1402
  "type":"string",
1383
1403
  "max":2500
@@ -1521,6 +1541,37 @@
1521
1541
  }
1522
1542
  },
1523
1543
  "NextToken":{"type":"string"},
1544
+ "NotificationArn":{"type":"string"},
1545
+ "NotificationConfig":{
1546
+ "type":"structure",
1547
+ "members":{
1548
+ "NotificationArn":{"shape":"NotificationArn"},
1549
+ "NotificationEvents":{"shape":"NotificationEventList"},
1550
+ "NotificationType":{"shape":"NotificationType"}
1551
+ }
1552
+ },
1553
+ "NotificationEvent":{
1554
+ "type":"string",
1555
+ "enum":[
1556
+ "All",
1557
+ "InProgress",
1558
+ "Success",
1559
+ "TimedOut",
1560
+ "Cancelled",
1561
+ "Failed"
1562
+ ]
1563
+ },
1564
+ "NotificationEventList":{
1565
+ "type":"list",
1566
+ "member":{"shape":"NotificationEvent"}
1567
+ },
1568
+ "NotificationType":{
1569
+ "type":"string",
1570
+ "enum":[
1571
+ "Command",
1572
+ "Invocation"
1573
+ ]
1574
+ },
1524
1575
  "ParameterName":{"type":"string"},
1525
1576
  "ParameterValue":{"type":"string"},
1526
1577
  "ParameterValueList":{
@@ -1626,7 +1677,9 @@
1626
1677
  "Comment":{"shape":"Comment"},
1627
1678
  "Parameters":{"shape":"Parameters"},
1628
1679
  "OutputS3BucketName":{"shape":"S3BucketName"},
1629
- "OutputS3KeyPrefix":{"shape":"S3KeyPrefix"}
1680
+ "OutputS3KeyPrefix":{"shape":"S3KeyPrefix"},
1681
+ "ServiceRoleArn":{"shape":"ServiceRole"},
1682
+ "NotificationConfig":{"shape":"NotificationConfig"}
1630
1683
  }
1631
1684
  },
1632
1685
  "SendCommandResult":{
@@ -1635,6 +1688,7 @@
1635
1688
  "Command":{"shape":"Command"}
1636
1689
  }
1637
1690
  },
1691
+ "ServiceRole":{"type":"string"},
1638
1692
  "StatusAdditionalInfo":{
1639
1693
  "type":"string",
1640
1694
  "max":1024
@@ -114,6 +114,7 @@ module Aws
114
114
  autoload :EmptyStructure, 'aws-sdk-core/empty_structure'
115
115
  autoload :EndpointProvider, 'aws-sdk-core/endpoint_provider'
116
116
  autoload :Errors, 'aws-sdk-core/errors'
117
+ autoload :IniParser, 'aws-sdk-core/ini_parser'
117
118
  autoload :InstanceProfileCredentials, 'aws-sdk-core/instance_profile_credentials'
118
119
  autoload :Json, 'aws-sdk-core/json'
119
120
  autoload :PageableResponse, 'aws-sdk-core/pageable_response'
@@ -123,6 +124,7 @@ module Aws
123
124
  autoload :Partitions, 'aws-sdk-core/partitions'
124
125
  autoload :RefreshingCredentials, 'aws-sdk-core/refreshing_credentials'
125
126
  autoload :Service, 'aws-sdk-core/service'
127
+ autoload :SharedConfig, 'aws-sdk-core/shared_config'
126
128
  autoload :SharedCredentials, 'aws-sdk-core/shared_credentials'
127
129
  autoload :Structure, 'aws-sdk-core/structure'
128
130
  autoload :TreeHash, 'aws-sdk-core/tree_hash'
@@ -274,6 +276,12 @@ module Aws
274
276
 
275
277
  class << self
276
278
 
279
+ # @api private
280
+ def shared_config
281
+ enabled = ENV["AWS_SDK_LOAD_CONFIG"] ? true : false
282
+ @shared_config ||= SharedConfig.new(config_enabled: true)
283
+ end
284
+
277
285
  # @return [Hash] Returns a hash of default configuration options shared
278
286
  # by all constructed clients.
279
287
  attr_reader :config
@@ -49,19 +49,9 @@ module Aws
49
49
 
50
50
  Api::Customizations.apply_plugins(client_class)
51
51
 
52
- soft_deprecation
53
52
  client_class
54
53
  end
55
54
 
56
- private
57
-
58
- def soft_deprecation
59
- unless @warned
60
- @warned = true
61
- warn('NEWER VERSION AVAILABLE: Please upgrade to AWS SDK For Ruby V3')
62
- end
63
- end
64
-
65
55
  end
66
56
  end
67
57
  end
@@ -21,6 +21,7 @@ module Aws
21
21
  [
22
22
  [:static_credentials, {}],
23
23
  [:env_credentials, {}],
24
+ [:assume_role_credentials, {}],
24
25
  [:shared_credentials, {}],
25
26
  [:instance_profile_credentials, {
26
27
  retries: 0,
@@ -67,6 +68,20 @@ module Aws
67
68
  nil
68
69
  end
69
70
 
71
+ def assume_role_credentials(options)
72
+ if Aws.shared_config.config_enabled?
73
+ profile, region = nil, nil
74
+ if options[:config]
75
+ profile = options[:config].profile
76
+ region = options[:config].region
77
+ assume_role_with_profile(options[:config].profile, options[:config].region)
78
+ end
79
+ assume_role_with_profile(profile, region)
80
+ else
81
+ nil
82
+ end
83
+ end
84
+
70
85
  def instance_profile_credentials(options)
71
86
  if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
72
87
  ECSCredentials.new(options)
@@ -75,5 +90,12 @@ module Aws
75
90
  end
76
91
  end
77
92
 
93
+ def assume_role_with_profile(prof, region)
94
+ Aws.shared_config.assume_role_credentials_from_config(
95
+ profile: prof,
96
+ region: region
97
+ )
98
+ end
99
+
78
100
  end
79
101
  end
@@ -42,6 +42,10 @@ module Aws
42
42
  # credentials profile does not exist.
43
43
  class NoSuchProfileError < RuntimeError; end
44
44
 
45
+ # Raised when a {Service} is constructed, where Assume Role credentials are
46
+ # expected, and there is no source profile specified.
47
+ class NoSourceProfileError < RuntimeError; end
48
+
45
49
  # Raised when a {Service} is constructed and credentials are not
46
50
  # set, or the set credentials are empty.
47
51
  class MissingCredentialsError < RuntimeError; end
@@ -0,0 +1,40 @@
1
+ module Aws
2
+ class IniParser
3
+ class << self
4
+
5
+ def ini_parse(raw)
6
+ current_profile = nil
7
+ current_prefix = nil
8
+ raw.lines.inject({}) do |acc, line|
9
+ line = line.split(/^|\s;/).first # remove comments
10
+ profile = line.match(/^\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
11
+ if profile
12
+ current_profile = profile[1]
13
+ named_profile = current_profile.match(/^profile\s+(.+?)$/)
14
+ current_profile = named_profile[1] if named_profile
15
+ elsif current_profile
16
+ unless line.nil?
17
+ item = line.match(/^(.+?)\s*=\s*(.+?)\s*$/)
18
+ prefix = line.match(/^(.+?)\s*=\s*$/)
19
+ end
20
+ if item && item[1].match(/^\s+/)
21
+ # Need to add lines to a nested configuration.
22
+ inner_item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/)
23
+ acc[current_profile] ||= {}
24
+ acc[current_profile][current_prefix] ||= {}
25
+ acc[current_profile][current_prefix][inner_item[1]] = inner_item[2]
26
+ elsif item
27
+ current_prefix = nil
28
+ acc[current_profile] ||= {}
29
+ acc[current_profile][item[1]] = item[2]
30
+ elsif prefix
31
+ current_prefix = prefix[1]
32
+ end
33
+ end
34
+ acc
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -14,10 +14,11 @@ module Aws
14
14
  # raised when region is not configured
15
15
  MISSING_REGION = 'missing required configuration option :region'
16
16
 
17
- option(:region) {
18
- keys = %w(AWS_REGION AMAZON_REGION AWS_DEFAULT_REGION)
19
- ENV.values_at(*keys).compact.first
20
- }
17
+ option(:profile)
18
+
19
+ option(:region) do |cfg|
20
+ resolve_region(cfg)
21
+ end
21
22
 
22
23
  option(:endpoint) do |cfg|
23
24
  if endpoint_prefix = cfg.api.metadata['endpointPrefix']
@@ -33,6 +34,15 @@ module Aws
33
34
  end
34
35
  end
35
36
 
37
+ private
38
+ def self.resolve_region(cfg)
39
+ keys = %w(AWS_REGION AMAZON_REGION AWS_DEFAULT_REGION)
40
+ env_region = ENV.values_at(*keys).compact.first
41
+ env_region = nil if env_region == ''
42
+ cfg_region = Aws.shared_config.region(profile: cfg.profile)
43
+ env_region || cfg_region
44
+ end
45
+
36
46
  end
37
47
  end
38
48
  end
@@ -0,0 +1,238 @@
1
+ module Aws
2
+
3
+ # @api private
4
+ class SharedConfig
5
+
6
+ # @return [String]
7
+ attr_reader :credentials_path
8
+
9
+ # @return [String]
10
+ attr_reader :config_path
11
+
12
+ # @return [String]
13
+ attr_reader :profile_name
14
+
15
+ # Constructs a new SharedConfig provider object. This will load the shared
16
+ # credentials file, and optionally the shared configuration file, as ini
17
+ # files which support profiles.
18
+ #
19
+ # By default, only the shared credential file (the default path for which is
20
+ # `~/.aws/credentials`) is loaded. However, if you set the
21
+ # `ENV['AWS_SDK_LOAD_CONFIG']` environment variable, the shared config file
22
+ # will also be loaded (the default path for which is `~/.aws/config`).
23
+ #
24
+ # The default profile name is 'default'. You can specify the profile name
25
+ # with the `ENV['AWS_PROFILE']` environment variable or with the
26
+ # `:profile_name` option.
27
+ #
28
+ # @param [Hash] options
29
+ # @option options [String] :credentials_path Path to the shared credentials
30
+ # file. Defaults to "#{Dir.home}/.aws/credentials".
31
+ # @option options [String] :config_path Path to the shared config file.
32
+ # Defaults to "#{Dir.home}/.aws/config".
33
+ # @option options [String] :profile_name The credential/config profile name
34
+ # to use. If not specified, will check `ENV['AWS_PROFILE']` before using
35
+ # the fixed default value of 'default'.
36
+ # @option options [Boolean] :config_enabled If true, loads the shared config
37
+ # file and enables new config values outside of the old shared credential
38
+ # spec. Generally sourced from `ENV['AWS_SDK_LOAD_CONFIG']`.
39
+ def initialize(options = {})
40
+ @profile_name = determine_profile(options)
41
+ @config_enabled = options[:config_enabled]
42
+ @credentials_path = options[:credentials_path] ||
43
+ determine_credentials_path
44
+ @parsed_credenetials = {}
45
+ load_credentials_file if loadable?(@credentials_path)
46
+ if @config_enabled
47
+ @config_path = options[:config_path] || determine_config_path
48
+ load_config_file if loadable?(@config_path)
49
+ end
50
+ end
51
+
52
+ # @api private
53
+ def fresh(options = {})
54
+ @profile_name = nil
55
+ @credentials_path = nil
56
+ @config_path = nil
57
+ @parsed_credentials = {}
58
+ @parsed_config = nil
59
+ @config_enabled = options[:config_enabled] ? true : false
60
+ @profile_name = determine_profile(options)
61
+ @credentials_path = options[:credentials_path] ||
62
+ determine_credentials_path
63
+ load_credentials_file if loadable?(@credentials_path)
64
+ if @config_enabled
65
+ @config_path = options[:config_path] || determine_config_path
66
+ load_config_file if loadable?(@config_path)
67
+ end
68
+ end
69
+
70
+ # @return [Boolean] Returns `true` if a credential file
71
+ # exists and has appropriate read permissions at {#path}.
72
+ # @note This method does not indicate if the file found at {#path}
73
+ # will be parsable, only if it can be read.
74
+ def loadable?(path)
75
+ !path.nil? && File.exist?(path) && File.readable?(path)
76
+ end
77
+
78
+ # @return [Boolean] returns `true` if use of the shared config file is
79
+ # enabled. Generally true if and only if the `AWS_SDK_LOAD_CONFIG` env
80
+ # variable is set.
81
+ def config_enabled?
82
+ @config_enabled ? true : false
83
+ end
84
+
85
+ # Sources static credentials from shared credential/config files.
86
+ #
87
+ # @param [Hash] options
88
+ # @option options [String] :profile the name of the configuration file from
89
+ # which credentials are being sourced.
90
+ # @return [Aws::Credentials] credentials sourced from configuration values,
91
+ # or `nil` if no valid credentials were found.
92
+ def credentials(opts = {})
93
+ p = opts[:profile] || @profile_name
94
+ validate_profile_exists(p) if @parsed_credentials || @parsed_config
95
+ if credentials = credentials_from_shared(p, opts)
96
+ credentials
97
+ elsif credentials = credentials_from_config(p, opts)
98
+ credentials
99
+ else
100
+ nil
101
+ end
102
+ end
103
+
104
+ # Attempts to assume a role from shared config or shared credentials file.
105
+ # Will always attempt first to assume a role from the shared credentials
106
+ # file, if present.
107
+ def assume_role_credentials_from_config(opts = {})
108
+ p = opts.delete(:profile) || @profile_name
109
+ credentials = assume_role_from_profile(@parsed_credentials, p, opts)
110
+ if @parsed_config
111
+ credentials ||= assume_role_from_profile(@parsed_config, p, opts)
112
+ end
113
+ credentials
114
+ end
115
+
116
+ def region(opts = {})
117
+ p = opts[:profile] || @profile_name
118
+ if @config_enabled
119
+ if @parsed_credentials
120
+ region = @parsed_credentials.fetch(p, {})["region"]
121
+ end
122
+ if @parsed_config
123
+ region ||= @parsed_config.fetch(p, {})["region"]
124
+ end
125
+ region
126
+ else
127
+ nil
128
+ end
129
+ end
130
+
131
+ private
132
+ def assume_role_from_profile(cfg, profile, opts)
133
+ if cfg && prof_cfg = cfg[profile]
134
+ opts[:source_profile] ||= prof_cfg["source_profile"]
135
+ if opts[:source_profile]
136
+ opts[:credentials] = credentials(profile: opts[:source_profile])
137
+ if opts[:credentials]
138
+ opts[:role_session_name] ||= prof_cfg["role_session_name"]
139
+ opts[:role_session_name] ||= "default_session"
140
+ opts[:role_arn] ||= prof_cfg["role_arn"]
141
+ opts[:external_id] ||= prof_cfg["external_id"]
142
+ opts[:serial_number] ||= prof_cfg["mfa_serial"]
143
+ opts[:profile] = opts.delete(:source_profile)
144
+ AssumeRoleCredentials.new(opts)
145
+ else
146
+ raise Errors::NoSourceProfileError.new(
147
+ "Profile #{profile} has a role_arn, and source_profile, but the"\
148
+ " source_profile does not have credentials."
149
+ )
150
+ end
151
+ elsif prof_cfg["role_arn"]
152
+ raise Errors::NoSourceProfileError.new(
153
+ "Profile #{profile} has a role_arn, but no source_profile."
154
+ )
155
+ else
156
+ nil
157
+ end
158
+ else
159
+ nil
160
+ end
161
+ end
162
+
163
+ def credentials_from_shared(profile, opts)
164
+ if @parsed_credentials && prof_config = @parsed_credentials[profile]
165
+ credentials_from_profile(prof_config)
166
+ else
167
+ nil
168
+ end
169
+ end
170
+
171
+ def credentials_from_config(profile, opts)
172
+ if @parsed_config && prof_config = @parsed_config[profile]
173
+ credentials_from_profile(prof_config)
174
+ else
175
+ nil
176
+ end
177
+ end
178
+
179
+ def credentials_from_profile(prof_config)
180
+ creds = Credentials.new(
181
+ prof_config['aws_access_key_id'],
182
+ prof_config['aws_secret_access_key'],
183
+ prof_config['aws_session_token']
184
+ )
185
+ if credentials_complete(creds)
186
+ creds
187
+ else
188
+ nil
189
+ end
190
+ end
191
+
192
+ def credentials_complete(creds)
193
+ creds.set?
194
+ end
195
+
196
+ def load_credentials_file
197
+ @parsed_credentials = IniParser.ini_parse(
198
+ File.read(@credentials_path)
199
+ )
200
+ end
201
+
202
+ def load_config_file
203
+ @parsed_config = IniParser.ini_parse(File.read(@config_path))
204
+ end
205
+
206
+ def determine_credentials_path
207
+ default = default_shared_config_path('credentials')
208
+ end
209
+
210
+ def determine_config_path
211
+ default = default_shared_config_path('config')
212
+ end
213
+
214
+ def default_shared_config_path(file)
215
+ File.join(Dir.home, '.aws', file)
216
+ rescue ArgumentError
217
+ # Dir.home raises ArgumentError when ENV['home'] is not set
218
+ nil
219
+ end
220
+
221
+ def validate_profile_exists(profile)
222
+ unless (@parsed_credentials && @parsed_credentials[profile]) ||
223
+ (@parsed_config && @parsed_config[profile])
224
+ msg = "Profile `#{profile}' not found in #{@credentials_path}"
225
+ msg << " or #{@config_path}" if @config_path
226
+ raise Errors::NoSuchProfileError.new(msg)
227
+ end
228
+ end
229
+
230
+ def determine_profile(options)
231
+ ret = options[:profile_name]
232
+ ret ||= ENV["AWS_PROFILE"]
233
+ ret ||= "default"
234
+ ret
235
+ end
236
+
237
+ end
238
+ end
@@ -22,11 +22,21 @@ module Aws
22
22
  # `ENV['AWS_PROFILE']`.
23
23
  #
24
24
  def initialize(options = {})
25
- @path = options[:path] || default_path
25
+ shared_config = Aws.shared_config
26
+ @path = options[:path]
27
+ @path ||= shared_config.credentials_path
26
28
  @profile_name = options[:profile_name]
27
29
  @profile_name ||= ENV['AWS_PROFILE']
28
- @profile_name ||= 'default'
29
- load_from_path if loadable?
30
+ @profile_name ||= shared_config.profile_name
31
+ if @path && @path == shared_config.credentials_path
32
+ @credentials = shared_config.credentials(profile: @profile_name)
33
+ else
34
+ config = SharedConfig.new(
35
+ credentials_path: @path,
36
+ profile_name: @profile_name
37
+ )
38
+ @credentials = config.credentials(profile: @profile_name)
39
+ end
30
40
  end
31
41
 
32
42
  # @return [String]
@@ -48,6 +58,7 @@ module Aws
48
58
  "#<#{parts.join(' ')}>"
49
59
  end
50
60
 
61
+ # @deprecated This method is no longer used.
51
62
  # @return [Boolean] Returns `true` if a credential file
52
63
  # exists and has appropriate read permissions at {#path}.
53
64
  # @note This method does not indicate if the file found at {#path}
@@ -56,55 +67,5 @@ module Aws
56
67
  !path.nil? && File.exist?(path) && File.readable?(path)
57
68
  end
58
69
 
59
- private
60
-
61
- def default_path
62
- File.join(Dir.home, '.aws', 'credentials')
63
- rescue ArgumentError
64
- # Dir.home raises ArgumentError when ENV['home'] is not set
65
- nil
66
- end
67
-
68
- def load_from_path
69
- profile = load_profile
70
- @credentials = Credentials.new(
71
- profile['aws_access_key_id'],
72
- profile['aws_secret_access_key'],
73
- profile['aws_session_token']
74
- )
75
- end
76
-
77
- def load_profile
78
- if profile = profiles[profile_name]
79
- profile
80
- else
81
- msg = "Profile `#{profile_name}' not found in #{path}"
82
- raise Errors::NoSuchProfileError, msg
83
- end
84
- end
85
-
86
- def profiles
87
- ini_parse(File.read(path))
88
- end
89
-
90
- def ini_parse(file)
91
- current_section = {}
92
- map = {}
93
- file.lines.each do |line|
94
- line = line.split(/^|\s;/).first # remove comments
95
- section = line.match(/^\s*\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
96
- if section
97
- current_section = section[1]
98
- elsif current_section
99
- item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/) unless line.nil?
100
- if item
101
- map[current_section] = map[current_section] || {}
102
- map[current_section][item[1]] = item[2]
103
- end
104
- end
105
- end
106
- map
107
- end
108
-
109
70
  end
110
71
  end
@@ -1,3 +1,3 @@
1
1
  module Aws
2
- VERSION = '2.3.23'
2
+ VERSION = '2.4.0'
3
3
  end
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.3.23
4
+ version: 2.4.0
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: 2020-02-13 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jmespath
@@ -317,6 +317,7 @@ files:
317
317
  - lib/aws-sdk-core/glacier.rb
318
318
  - lib/aws-sdk-core/iam.rb
319
319
  - lib/aws-sdk-core/importexport.rb
320
+ - lib/aws-sdk-core/ini_parser.rb
320
321
  - lib/aws-sdk-core/inspector.rb
321
322
  - lib/aws-sdk-core/instance_profile_credentials.rb
322
323
  - lib/aws-sdk-core/iot.rb
@@ -416,6 +417,7 @@ files:
416
417
  - lib/aws-sdk-core/service.rb
417
418
  - lib/aws-sdk-core/servicecatalog.rb
418
419
  - lib/aws-sdk-core/ses.rb
420
+ - lib/aws-sdk-core/shared_config.rb
419
421
  - lib/aws-sdk-core/shared_credentials.rb
420
422
  - lib/aws-sdk-core/signers/base.rb
421
423
  - lib/aws-sdk-core/signers/s3.rb
@@ -507,8 +509,7 @@ homepage: http://github.com/aws/aws-sdk-ruby
507
509
  licenses:
508
510
  - Apache 2.0
509
511
  metadata: {}
510
- post_install_message: 'NEWER VERSION AVAILABLE: Please upgrade to AWS SDK For Ruby
511
- V3'
512
+ post_install_message:
512
513
  rdoc_options: []
513
514
  require_paths:
514
515
  - lib
@@ -523,8 +524,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
523
524
  - !ruby/object:Gem::Version
524
525
  version: '0'
525
526
  requirements: []
526
- rubygems_version: 3.0.3
527
+ rubyforge_project:
528
+ rubygems_version: 2.5.1
527
529
  signing_key:
528
530
  specification_version: 4
529
531
  summary: AWS SDK for Ruby - Core
530
532
  test_files: []
533
+ has_rdoc: