Example AutoScale Heat template (Windows)

hello_world_autoscaling_windows.yaml

The following is an example template for AutoScale (Windows).

heat_template_version: 2013-05-23

description:
  Autoscaling Windows

parameters: 

  az:
    type: string
    default: jp-east-1a
  param_image_id:
    type: string
    default: 5ab16551-c229-4611-834b-a16e074c187e
  param_flavor:
    type: string
    default: (The server type of the virtual server.) 
  autoscale_security_group_name:
    type: comma_delimited_list
    default: (Arbitrary security group name)
  autoscale_security_group_id:
    type: comma_delimited_list
    default: (Arbitrary security group ID)
  autoscale_subnet_id:
    type: comma_delimited_list
    default: (Arbitrary subnet ID)
  autoscale_elb_name:
    type: string
    default: m0918WinELB1

resources:

  AutoScaleWindows:
    type: FCX::AutoScaling::AutoScalingGroup
    properties:
      AvailabilityZones: [{get_param: az}]
      LaunchConfigurationName: {get_resource: launch_config}
      MinSize: '1'
      MaxSize: '3'
      VPCZoneIdentifier: {get_param: autoscale_subnet_id}
      HealthCheckGracePeriod: '110'
      HealthCheckType: 'ELB'
      Cooldown: 750
      LoadBalancerNames: [{get_resource: fj_elb}]
      Tags: [{"Key": "admin_pass", "Value": "(Arbitrary password (*1))"}]
        *1: Specify a password that satisfies the complexity
          requirements of Windows. 

  launch_config:
    type: FCX::AutoScaling::LaunchConfiguration
    properties:
      ImageId: { get_param: param_image_id }
      InstanceType: { get_param: param_flavor }
      SecurityGroups: {get_param: autoscale_security_group_name}
      BlockDeviceMappingsV2: [{source_type: 'image', destination_type: 'volume', boot_index: '0', device_name: '/dev/vda', volume_size: '80', uuid: {get_param: param_image_id}, delete_on_termination: true, volume_type: 'F2'}]
      UserData: |
        #ps1
        New-Item "c:\\test" -itemType Directory

  fj_elb:
    type: FCX::ExpandableLoadBalancer::LoadBalancer
    properties:
      Subnets: {get_param: autoscale_subnet_id}
      SecurityGroups: {get_param: autoscale_security_group_id}
      Listeners:
      - {LoadBalancerPort: '80', InstancePort: '80',
        Protocol: 'HTTP', InstanceProtocol: 'HTTP' }
      HealthCheck: {Target: 'HTTP:80/iisstart.htm', HealthyThreshold: '3',
                   UnhealthyThreshold: '5', Interval: '30', Timeout: '5'}
      Version: 2014-09-30
      Scheme: internal
      LoadBalancerName: {get_param: autoscale_elb_name}

  web_server_scaleup_policy:
    type: FCX::AutoScaling::ScalingPolicy
    properties:
      AdjustmentType: ChangeInCapacity
      AutoScalingGroupName: {get_resource: AutoScaleWindows}
      ScalingAdjustment: '1'

  web_server_scaledown_policy:
    type: FCX::AutoScaling::ScalingPolicy
    properties:
      AdjustmentType: ChangeInCapacity
      AutoScalingGroupName: {get_resource: AutoScaleWindows}
      ScalingAdjustment: '-1'

  cpu_alarm_high:
    type: OS::Ceilometer::Alarm
    properties:
      description: Scale-up if the average CPU > 80% for 1 minute
      meter_name: fcx.compute.cpu_util
      statistic: avg
      period: '180'
      evaluation_periods: '1'
      threshold: '80'
      alarm_actions:
      - {get_attr: [web_server_scaleup_policy, AlarmUrl]}
      matching_metadata: {'metadata.user_metadata.groupname': {get_resource: 'AutoScaleWindows'}}
      comparison_operator: gt

  cpu_alarm_low:
    type: OS::Ceilometer::Alarm
    properties:
      description: Scale-down if the average CPU < 20% for 1 minute
      meter_name: fcx.compute.cpu_util
      statistic: avg
      period: '180'
      evaluation_periods: '1'
      threshold: '20'
      alarm_actions: 
      - {get_attr: [web_server_scaledown_policy, AlarmUrl]}
      matching_metadata: {'metadata.user_metadata.groupname': {get_resource: 'AutoScaleWindows'}}
      comparison_operator: lt