aws-sdk 1.11.3 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -94,6 +94,8 @@ module AWS
94
94
 
95
95
  attribute :placement_group
96
96
 
97
+ attribute :termination_policies
98
+
97
99
  attribute :suspended_processes do
98
100
  translates_output do |processes|
99
101
  processes.inject({}) do |hash,process|
@@ -61,6 +61,14 @@ module AWS
61
61
  # Amazon EC2. For more information about cluster placement group, see
62
62
  # [Using Cluster Instances](http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using_cluster_computing.html).
63
63
  #
64
+ # @option options [Array<String>] :termination_policies
65
+ # A standalone termination policy or a list of termination policies used
66
+ # to select the instance to terminate. The policies are executed in the
67
+ # order they are listed. For more information on creating a termination
68
+ # policy for your Auto Scaling group, go to
69
+ # [Instance Termination Policy for Your Auto Scaling Group](http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/us-termination-policy.html)
70
+ # in the Auto Scaling Developer Guide.
71
+ #
64
72
  # @option options [Array<Hash>] :tags A list of tags to apply launched
65
73
  # instances. Each tag hash may have the following keys:
66
74
  #
@@ -102,6 +110,7 @@ module AWS
102
110
  :desired_capacity,
103
111
  :health_check_grace_period,
104
112
  :placement_group,
113
+ :termination_policies,
105
114
  ].each do |opt|
106
115
  group_opts[opt] = options[opt] if options.key?(opt)
107
116
  end
@@ -97,9 +97,7 @@ module AWS
97
97
  # should be a Hash with a `:name` and `:value`.
98
98
  # @return [MetricCollection]
99
99
  def with_dimensions *dimensions
100
- dimensions = @filters[:dimensions] || []
101
- dimensions += dimensions.flatten
102
- filter(:dimensions, dimensions)
100
+ filter(:dimensions, (@filters[:dimensions] || []) + dimensions.flatten )
103
101
  end
104
102
 
105
103
  protected
@@ -12,6 +12,7 @@
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
14
  require 'aws/version'
15
+ require 'set'
15
16
 
16
17
  # AWS is the root module for all of the Amazon Web Services. It is also
17
18
  # where you can configure you access to AWS.
@@ -32,98 +33,112 @@ require 'aws/version'
32
33
  module AWS
33
34
 
34
35
  # @api private
35
- SERVICES = {
36
- "CloudFront" => {
36
+ class SvcDetails
37
+ def initialize class_name, options
38
+ @class_name = class_name
39
+ @full_name = options[:full_name]
40
+ @method_name = options[:method_name]
41
+ @method_alias = options[:method_alias]
42
+ @old_name = @method_alias || @method_name
43
+ end
44
+ attr_reader :class_name, :full_name, :method_name, :method_alias, :old_name
45
+ end
46
+
47
+ # @api private
48
+ SERVICES = [
49
+ SvcDetails.new("CloudFront",
37
50
  :full_name => "Amazon CloudFront",
38
- :ruby_name => :cloud_front },
39
- "CloudSearch" => {
51
+ :method_name => :cloud_front),
52
+ SvcDetails.new("CloudSearch",
40
53
  :full_name => "Amazon CloudSearch",
41
- :ruby_name => :cloud_search },
42
- "CloudWatch" => {
54
+ :method_name => :cloud_search),
55
+ SvcDetails.new("CloudWatch",
43
56
  :full_name => "Amazon CloudWatch",
44
- :ruby_name => :cloud_watch },
45
- "DynamoDB" => {
57
+ :method_name => :cloud_watch),
58
+ SvcDetails.new("DynamoDB",
46
59
  :full_name => "Amazon DynamoDB",
47
- :ruby_name => :dynamo_db },
48
- "EC2" => {
60
+ :method_name => :dynamo_db),
61
+ SvcDetails.new("EC2",
49
62
  :full_name => "Amazon Elastic Compute Cloud",
50
- :ruby_name => :ec2 },
51
- "EMR" => {
63
+ :method_name => :ec2),
64
+ SvcDetails.new("EMR",
52
65
  :full_name => "Amazon Elastic MapReduce",
53
- :ruby_name => :emr },
54
- "ElastiCache" => {
66
+ :method_name => :emr),
67
+ SvcDetails.new("ElastiCache",
55
68
  :full_name => "Amazon ElastiCache",
56
- :ruby_name => :elasticache },
57
- "Glacier" => {
69
+ :method_name => :elasticache),
70
+ SvcDetails.new("Glacier",
58
71
  :full_name => "Amazon Glacier",
59
- :ruby_name => :glacier },
60
- "RDS" => {
72
+ :method_name => :glacier),
73
+ SvcDetails.new("RDS",
61
74
  :full_name => "Amazon Relational Database Service (Beta)",
62
- :ruby_name => :rds },
63
- "Route53" => {
75
+ :method_name => :rds),
76
+ SvcDetails.new("Route53",
64
77
  :full_name => "Amazon Route 53",
65
- :ruby_name => :route_53 },
66
- "SimpleEmailService" => {
78
+ :method_name => :route_53),
79
+ SvcDetails.new("SimpleEmailService",
67
80
  :full_name => "Amazon Simple E-mail Service",
68
- :ruby_name => :simple_email_service },
69
- "SNS" => {
81
+ :method_name => :ses,
82
+ :method_alias => :simple_email_service),
83
+ SvcDetails.new("SNS",
70
84
  :full_name => "Amazon Simple Notifications Service",
71
- :ruby_name => :sns },
72
- "SQS" => {
85
+ :method_name => :sns),
86
+ SvcDetails.new("SQS",
73
87
  :full_name => "Amazon Simple Queue Service",
74
- :ruby_name => :sqs },
75
- "SimpleWorkflow" => {
88
+ :method_name => :sqs),
89
+ SvcDetails.new("SimpleWorkflow",
76
90
  :full_name => "Amazon Simple Workflow Service",
77
- :ruby_name => :simple_workflow },
78
- "SimpleDB" => {
91
+ :method_name => :swf,
92
+ :method_alias => :simple_workflow),
93
+ SvcDetails.new("SimpleDB",
79
94
  :full_name => "Amazon SimpleDB",
80
- :ruby_name => :simple_db },
81
- "AutoScaling" => {
95
+ :method_name => :simple_db),
96
+ SvcDetails.new("AutoScaling",
82
97
  :full_name => "Auto Scaling",
83
- :ruby_name => :auto_scaling },
84
- "CloudFormation" => {
98
+ :method_name => :auto_scaling),
99
+ SvcDetails.new("CloudFormation",
85
100
  :full_name => "AWS CloudFormation",
86
- :ruby_name => :cloud_formation },
87
- "DataPipeline" => {
101
+ :method_name => :cloud_formation),
102
+ SvcDetails.new("DataPipeline",
88
103
  :full_name => "AWS Data Pipeline",
89
- :ruby_name => :data_pipeline },
90
- "DirectConnect" => {
104
+ :method_name => :data_pipeline),
105
+ SvcDetails.new("DirectConnect",
91
106
  :full_name => "AWS Direct Connect",
92
- :ruby_name => :direct_connect },
93
- "ElasticBeanstalk" => {
107
+ :method_name => :direct_connect),
108
+ SvcDetails.new("ElasticBeanstalk",
94
109
  :full_name => "AWS Elastic Beanstalk",
95
- :ruby_name => :elastic_beanstalk },
96
- "IAM" => {
110
+ :method_name => :elastic_beanstalk),
111
+ SvcDetails.new("IAM",
97
112
  :full_name => "AWS Identity and Access Management",
98
- :ruby_name => :iam },
99
- "ImportExport" => {
113
+ :method_name => :iam),
114
+ SvcDetails.new("ImportExport",
100
115
  :full_name => "AWS Import/Export",
101
- :ruby_name => :import_export },
102
- "OpsWorks" => {
116
+ :method_name => :import_export),
117
+ SvcDetails.new("OpsWorks",
103
118
  :full_name => "AWS OpsWorks",
104
- :ruby_name => :ops_works },
105
- "STS" => {
119
+ :method_name => :ops_works),
120
+ SvcDetails.new("STS",
106
121
  :full_name => "AWS Security Token Service",
107
- :ruby_name => :sts },
108
- "StorageGateway" => {
122
+ :method_name => :sts),
123
+ SvcDetails.new("StorageGateway",
109
124
  :full_name => "AWS Storage Gateway",
110
- :ruby_name => :storage_gateway },
111
- "Support" => {
125
+ :method_name => :storage_gateway),
126
+ SvcDetails.new("Support",
112
127
  :full_name => "AWS Support",
113
- :ruby_name => :support },
114
- "ELB" => {
128
+ :method_name => :support),
129
+ SvcDetails.new("ELB",
115
130
  :full_name => "Elastic Load Balancing",
116
- :ruby_name => :elb },
117
- "ElasticTranscoder" => {
131
+ :method_name => :elb),
132
+ SvcDetails.new("ElasticTranscoder",
118
133
  :full_name => "Amazon Elastic Transcoder",
119
- :ruby_name => :elastic_transcoder },
120
- "Redshift" => {
134
+ :method_name => :elastic_transcoder),
135
+ SvcDetails.new("Redshift",
121
136
  :full_name => "Amazon Redshift",
122
- :ruby_name => :redshift },
123
- "S3" => {
137
+ :method_name => :redshift),
138
+ SvcDetails.new("S3",
124
139
  :full_name => "Amazon Simple Storage Service",
125
- :ruby_name => :s3 }
126
- }
140
+ :method_name => :s3)
141
+ ].inject({}) { |h,svc| h[svc.class_name] = svc; h }
127
142
 
128
143
  # @api private
129
144
  ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
@@ -222,100 +237,11 @@ module AWS
222
237
 
223
238
  class << self
224
239
 
225
- # @!method cloud_front
226
- # @return [CloudFront]
227
-
228
- # @!method cloud_search
229
- # @return [CloudSearch]
230
-
231
- # @!method cloud_watch
232
- # @return [CloudWatch]
233
-
234
- # @!method dynamo_db
235
- # @return [DynamoDB]
236
-
237
- # @!method ec2
238
- # @return [EC2]
239
-
240
- # @!method emr
241
- # @return [EMR]
242
-
243
- # @!method elasticache
244
- # @return [ElastiCache]
245
-
246
- # @!method glacier
247
- # @return [Glacier]
248
-
249
- # @!method rds
250
- # @return [RDS]
251
-
252
- # @!method route_53
253
- # @return [Route53]
254
-
255
- # @!method simple_email_service
256
- # @return [SimpleEmailService]
257
-
258
- # @!method sns
259
- # @return [SNS]
260
-
261
- # @!method sqs
262
- # @return [SQS]
263
-
264
- # @!method simple_workflow
265
- # @return [SimpleWorkflow]
266
-
267
- # @!method simple_db
268
- # @return [SimpleDB]
269
-
270
- # @!method auto_scaling
271
- # @return [AutoScaling]
272
-
273
- # @!method cloud_formation
274
- # @return [CloudFormation]
275
-
276
- # @!method data_pipeline
277
- # @return [DataPipeline]
278
-
279
- # @!method direct_connect
280
- # @return [DirectConnect]
281
-
282
- # @!method elastic_beanstalk
283
- # @return [ElasticBeanstalk]
284
-
285
- # @!method iam
286
- # @return [IAM]
287
-
288
- # @!method import_export
289
- # @return [ImportExport]
290
-
291
- # @!method ops_works
292
- # @return [OpsWorks]
293
-
294
- # @!method sts
295
- # @return [STS]
296
-
297
- # @!method storage_gateway
298
- # @return [StorageGateway]
299
-
300
- # @!method support
301
- # @return [Support]
302
-
303
- # @!method elb
304
- # @return [ELB]
305
-
306
- # @!method elastic_transcoder
307
- # @return [ElasticTranscoder]
308
-
309
- # @!method redshift
310
- # @return [Redshift]
311
-
312
- # @!method s3
313
- # @return [S3]
314
-
315
- SERVICES.each_pair do |klass,svc|
316
- define_method(svc[:ruby_name]) do |*args|
317
- AWS.const_get(klass).new(args.first || {})
240
+ SERVICES.values.each do |svc|
241
+ define_method(svc.method_name) do |*args|
242
+ AWS.const_get(svc.class_name).new(args.first || {})
318
243
  end
244
+ alias_method(svc.method_alias, svc.method_name) if svc.method_alias
319
245
  end
320
246
 
321
247
  # @api private
@@ -568,6 +494,18 @@ module AWS
568
494
  Core::RegionCollection.new
569
495
  end
570
496
 
497
+ # @note Memoization is currently only supported for the EC2 APIs;
498
+ # other APIs are unaffected by the status of memoization. To
499
+ # protect your code from future changes in memoization support,
500
+ # you should not enable memoization while calling non-EC2 APIs.
501
+ #
502
+ # Resets memoizing service requests made in the current thread.
503
+ # See {memoize} for a full discussion of the memoization feature.
504
+ # This has no effect if memoization is already enabled.
505
+ def reset_memoization
506
+ Thread.current[:aws_memoization] = {}
507
+ end
508
+
571
509
  # @note Memoization is currently only supported for the EC2 APIs;
572
510
  # other APIs are unaffected by the status of memoization. To
573
511
  # protect your code from future changes in memoization support,
@@ -690,13 +628,16 @@ module AWS
690
628
  end
691
629
 
692
630
  # Eagerly loads all AWS classes/modules registered with autoload.
693
- # @return [nil]
694
- def eager_autoload! klass_or_module = AWS
631
+ # @return [void]
632
+ def eager_autoload! klass_or_module = AWS, visited = Set.new
695
633
  klass_or_module.constants.each do |const_name|
696
- if path = klass_or_module.autoload?(const_name)
697
- require(path)
698
- if const = klass_or_module.const_get(const_name) and const.is_a?(Module)
699
- eager_autoload!(const)
634
+ path = klass_or_module.autoload?(const_name)
635
+ require(path) if path
636
+ const = klass_or_module.const_get(const_name)
637
+ if const.is_a?(Module)
638
+ unless visited.include?(const)
639
+ visited << const
640
+ eager_autoload!(const, visited)
700
641
  end
701
642
  end
702
643
  end
@@ -719,13 +660,13 @@ module AWS
719
660
  pattern = File.join(File.dirname(__FILE__), 'api_config', '*.yml')
720
661
  Dir.glob(pattern).each do |path|
721
662
  matches = path.match(/(\w+)-(\d{4}-\d{2}-\d{2})/)
722
- svc = SERVICES[$1][:full_name]
663
+ svc = SERVICES[$1].full_name
723
664
  versions[svc] ||= []
724
665
  versions[svc] << $2
725
666
  end
726
667
 
727
668
  # s3 does not have an API configuration, so we have to add it manually
728
- versions[SERVICES['S3'][:full_name]] = ['2006-03-01']
669
+ versions[SERVICES['S3'].full_name] = ['2006-03-01']
729
670
 
730
671
  # sort the services alphabetically
731
672
  versions.keys.sort_by(&:downcase).inject({}) do |hash,svc|
@@ -736,9 +677,9 @@ module AWS
736
677
  end
737
678
  end
738
679
 
739
- SERVICES.each_pair do |klass,service|
740
- autoload(klass, "aws/#{service[:ruby_name]}")
741
- require "aws/#{service[:ruby_name]}/config"
680
+ SERVICES.values.each do |svc|
681
+ autoload(svc.class_name, "aws/#{svc.old_name}")
682
+ require "aws/#{svc.old_name}/config"
742
683
  end
743
684
 
744
685
  end
@@ -45,7 +45,7 @@ module AWS
45
45
  # configuration values, call {#with}, passing in the updates
46
46
  # and a new configuration object will be returned.
47
47
  #
48
- # config = Configuration.new(:max_retires => 3)
48
+ # config = Configuration.new(:max_retries => 3)
49
49
  # new_config = config.with(:max_retries => 2)
50
50
  #
51
51
  # config.max_retries #=> 3
@@ -377,9 +377,17 @@ module AWS
377
377
 
378
378
  def add_service name, ruby_name, endpoint_pattern = nil, &endpoint_builder
379
379
 
380
+ svc = SERVICES[name]
381
+ svc_opt = svc.method_name
382
+ ruby_name = svc.old_name
383
+
384
+ add_option(svc_opt, {})
385
+
380
386
  add_option :"#{ruby_name}_endpoint" do |config,value|
381
387
  if value
382
388
  value
389
+ elsif endpoint = config.send(svc_opt)[:endpoint]
390
+ endpoint
383
391
  elsif endpoint_pattern
384
392
  endpoint_pattern % config.region
385
393
  else
@@ -388,13 +396,23 @@ module AWS
388
396
  end
389
397
 
390
398
  add_option(:"#{ruby_name}_port") do |config,value|
391
- value || (config.use_ssl? ? 443 : 80)
399
+ if value
400
+ value
401
+ elsif port = config.send(svc_opt)[:port]
402
+ port
403
+ else
404
+ config.use_ssl? ? 443 : 80
405
+ end
392
406
  end
393
407
 
394
408
  # users only need to specify service regions when they use
395
409
  # a test endpoint with a sigv4 service
396
410
  add_option(:"#{ruby_name}_region") do |config,value|
397
- value || begin
411
+ if value
412
+ value
413
+ elsif region = config.send(svc_opt)[:region]
414
+ region
415
+ else
398
416
  endpoint = config.send("#{ruby_name}_endpoint")
399
417
  if endpoint =~ /us-gov/
400
418
  if matches = endpoint.match(/(us-gov-west-\d+)/)
@@ -467,7 +485,7 @@ module AWS
467
485
 
468
486
  add_option :http_continue_threshold, false
469
487
 
470
- add_option :http_idle_timeout, 60
488
+ add_option :http_idle_timeout, 5
471
489
 
472
490
  add_option :http_wire_trace, false, :boolean => true
473
491