heat_template_version: 2013-05-23

description: simple template to scale up

parameters:

  flavor:
    type: string
    default: m1.small

  image:
    type: string

  network:
    type: string


resources:

   my_asg:

     type: OS::Heat::AutoScalingGroup
     properties:
       resource:
         type: OS::Nova::Server
         properties:
           image: { get_param: image }
           flavor: { get_param: flavor }
           networks: [{network: {get_param: network} }]
       min_size: 1
       desired_capacity: 3
       max_size: 10

   scale_up_policy:
     type: OS::Heat::ScalingPolicy
     properties:
        adjustment_type: change_in_capacity
        auto_scaling_group_id: {get_resource: my_asg}
        cooldown: 60
        scaling_adjustment: 1

   cpu_alarm_high:
     type: OS::Ceilometer::Alarm
     properties:
       description: Scale-up if the average CPU > 50% for 1 minute
       meter_name: cpu_util
       statistic: avg
       period: 60
       evaluation_periods: 1
       threshold: 20.0
       alarm_actions:
         - {get_attr: [scale_up_policy, alarm_url]}
       comparison_operator: gt


outputs:
  scale_up_url:
   value: {get_attr: [scale_up_policy, alarm_url]}
