Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow setting namespace when creating/updating autoscaling triggers

Namespace is important; the triggers don't mean anything without it.
  • Loading branch information...
commit a14ec02148f839e875529b2c5fad29a065ab671b 1 parent f45aff2
@wlach wlach authored
View
2  lib/AWS/Autoscaling/autoscaling.rb
@@ -73,6 +73,7 @@ def create_autoscaling_group( options = {} )
# When called as a hash, the values must look like: {:name => "name", :value => "value"}
# In the array format, the first value is assumed to be the name and the second is assumed to be the value
# @option options [String] :measure_name (nil) the measure name associated with the metric used by the trigger
+ # @option options [optional,String] :namespace (nil) namespace of the metric on which to trigger. Used to describe the monitoring metric.
# @option options [String|Integer] :period (nil) the period associated with the metric in seconds
# @option options [String] :statistic (nil) The particular statistic used by the trigger when fetching metric statistics to examine. Must be one of the following: Minimum, Maximum, Sum, Average
# @option options [String] :trigger_name (nil) the name for this trigger
@@ -115,6 +116,7 @@ def create_or_updated_scaling_trigger( options = {} )
raise ArgumentError, "Dimensionss must be either an array or a hash"
end
params['MeasureName'] = options[:measure_name]
+ params['Namespace'] = options[:namespace] if options[:namespace]
params['Statistic'] = options[:statistic]
params['Period'] = options[:period].to_s
params['TriggerName'] = options[:trigger_name]
View
5 test/test_Autoscaling_groups.rb
@@ -110,10 +110,11 @@
'LowerBreachScaleIncrement' => "-1",
'UpperThreshold' => "1.5",
'UpperBreachScaleIncrement' => "1",
- 'BreachDuration' => "120"
+ 'BreachDuration' => "120",
+ 'Namespace' => "AWS/EC2",
}).returns stub(:body => @create_or_update_trigger_response, :is_a? => true)
- valid_create_or_update_scaling_trigger_params = {:autoscaling_group_name => "AutoScalingGroupName", :dimensions => {:name => "AutoScalingGroupName", :value => "Bob"}, :unit => "Seconds", :measure_name => "CPUUtilization", :statistic => "Average", :period => 120, :trigger_name => "AFunNameForATrigger", :lower_threshold => 0.2, :lower_breach_scale_increment => "-1", :upper_threshold => 1.5, :upper_breach_scale_increment => 1, :breach_duration => 120}
+ valid_create_or_update_scaling_trigger_params = {:autoscaling_group_name => "AutoScalingGroupName", :dimensions => {:name => "AutoScalingGroupName", :value => "Bob"}, :unit => "Seconds", :measure_name => "CPUUtilization", :namespace => "AWS/EC2", :statistic => "Average", :period => 120, :trigger_name => "AFunNameForATrigger", :lower_threshold => 0.2, :lower_breach_scale_increment => "-1", :upper_threshold => 1.5, :upper_breach_scale_increment => 1, :breach_duration => 120}
%w(dimensions autoscaling_group_name measure_name statistic period trigger_name lower_threshold lower_breach_scale_increment upper_threshold upper_breach_scale_increment breach_duration).each do |meth_str|
lambda { @as.create_or_updated_scaling_trigger(valid_create_or_update_scaling_trigger_params.merge(meth_str.to_sym=>nil)) }.should.raise(AWS::ArgumentError)
Please sign in to comment.
Something went wrong with that request. Please try again.