Reputation: 37419
I'm using a ruby script to help facilitate managing AutoScaling on AWS EC2. I've managed to create AMI
s, create LaunchConfigurations
, create ScalingGroups
, and associating one another.
I'm trying to clone a scaling group, copying its launch configurations, load balancers, etc. and its scaling policies.
To copy its scaling policy I have this code:
orig_scaling_group.scaling_policies.each do |policy|
props = Hash[%i(adjustment_type scaling_adjustment cooldown min_adjustment_step alarms).map { |s| [s, policy.send(s)] }.reject { |k, v| v.nil? }]
clone_scaling_group.scaling_policies[policy.name].put(props)
end
(scaling_groups are instances of AWS::AutoScaling::Group
)
This goes over the original's scaling policies, and extracts the data from it, and sets it as a new policy in the clone scaling group.
This works fine, except that it does not copy the alarms to the new policy. I could not find anyway in which I can programmatically assign an alarm to a scaling policy.
How can I do it?
Upvotes: 0
Views: 393
Reputation: 23522
I could not find anyway in which I can programmatically assign an alarm to a scaling policy.
I will be restricting my response to above statement.
In AWS Core Ruby SDK, under put_metric_alarm-instance_method
API, you can use alarm_actions
method. From above referred documentation:
Please note that, above information is relevant to AWS CORE SDK Ruby and not the older AWS ruby SDK.
Also for AWS-CLI, the similar settings can be found with put-metric-alarm for --alarm-actions
option.
Not sure whether this what you are looking for, but here I can certainly see a programmatic way of assigning an alarm to an Autoscaling policy.
Hope this helps.
Upvotes: 2