Skip to content

Instantly share code, notes, and snippets.

@tatat
Created September 11, 2013 09:18
Show Gist options
  • Save tatat/6521238 to your computer and use it in GitHub Desktop.
Save tatat/6521238 to your computer and use it in GitHub Desktop.
AutoScaling 一部抜粋(変数要脳内補完)
launch_configuration = auto_scaling.launch_configurations.create(
name,
ami.id,
as_instance_type,
key_pair: as_key_pair,
security_groups: as_security_groups,
)
auto_scaling_group = auto_scaling.groups.create(
name,
load_balancers: as_load_balancers,
min_size: as_min_size,
max_size: as_max_size,
launch_configuration: launch_configuration,
availability_zones: as_availability_zones,
health_check_type: as_load_balancers.empty? ? :ec2 : :elb,
health_check_grace_period: 240,
)
scale_up_policy = auto_scaling_group.scaling_policies.create(
name,
adjustment_type: 'ChangeInCapacity',
scaling_adjustment: as_min_size,
cooldown: 180,
)
alarm_high_cpu = cloud_watch.alarms.create(
name,
namespace: 'AWS/EC2',
metric_name: 'CPUUtilization',
dimensions: [{:name => 'AutoScalingGroupName', :value => auto_scaling_group.name}],
comparison_operator: 'GreaterThanThreshold',
evaluation_periods: 1,
period: 60,
statistic: 'Average',
threshold: as_alarm_high_cpu_threshold,
alarm_actions: [scale_up_policy.arn],
unit: 'Percent',
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment