# Pastebin y0m68xAZ mwheckmann: { "AWSTemplateFormatVersion" : "2010-09-09", "Parameters" : { "KeyName" : { "Description" : "Name of an existing KeyPair to enable SSH access to the instance", "Type" : "String" }, "InstanceType" : { "Description" : "Instance type", "Type" : "String", "Default" : "m1.small", "AllowedValues" : [ "m1.small" ], "ConstraintDescription" : "must be a valid instance type." }, "Image": { "Default": "redhat", "Description" : "Distribution of choice", "Type": "String", "AllowedValues" : [ "cirros", "redhat" ] }, "MinPoolSize" : { "Default": "1", "Description": "Minimum Size of the Scaling Pool", "Type": "String" }, "MaxPoolSize" : { "Default": "10", "Description": "Maximum size of the Scaling Pool", "Type": "String" } }, "Mappings" : { "DistroArch2AMI": { "cirros" : { "64" : "cirros-0.3.1-x86_64" }, "redhat" : { "64" : "RedHat_6.4_x86_64" } } }, "Resources" : { "Nodes" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "AvailabilityZones" : { "Fn::GetAZs" : ""}, "LaunchConfigurationName" : { "Ref" : "LaunchConfig" }, "MinSize" : { "Ref" : "MinPoolSize" }, "MaxSize" : { "Ref" : "MaxPoolSize" } } }, "LaunchConfig" : { "Type" : "AWS::AutoScaling::LaunchConfiguration", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { } } }, "Properties" : { "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "Image" }, "64" ] }, "InstanceType": { "Ref" : "InstanceType" }, "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash\n", "if [ -e '/root/setup.sh' ]; then exec /root/setup.sh; fi\n" ]] } } } }, "ScaleUpPolicy" : { "Type" : "AWS::AutoScaling::ScalingPolicy", "Properties" : { "AdjustmentType" : "ChangeInCapacity", "AutoScalingGroupName" : { "Ref" : "Nodes" }, "Cooldown" : "60", "ScalingAdjustment" : "1" } }, "ScaleDownPolicy" : { "Type" : "AWS::AutoScaling::ScalingPolicy", "Properties" : { "AdjustmentType" : "ChangeInCapacity", "AutoScalingGroupName" : { "Ref" : "Nodes" }, "Cooldown" : "60", "ScalingAdjustment" : "-1" } }, "CPUHighAlarm" : { "Type" : "OS::Ceilometer::Alarm", "Properties" : { "description" : "Scale up with CPU > 80% for 1 minute", "meter_name" : "cpu_util", "statistic" : "avg", "period" : "60", "evaluation_periods" : "1", "threshold" : "80", "alarm_actions" : [ { "Ref" : "ScaleUpPolicy" } ], "matching_metadata" : { "metadata.user_metadata.groupname" : { "Ref" : "Nodes" } }, "comparison_operator" : "gt" } }, "CPULowlarm" : { "Type" : "OS::Ceilometer::Alarm", "Properties" : { "description" : "Scale down with CPU < 40% for 5 minute", "meter_name" : "cpu_util", "statistic" : "avg", "period" : "300", "evaluation_periods" : "1", "threshold" : "40", "alarm_actions" : [ { "Ref" : "ScaleDownPolicy" } ], "matching_metadata" : { "metadata.user_metadata.groupname" : { "Ref" : "Nodes" } }, "comparison_operator" : "lt" } } }, "Outputs" : { "ScaleUpTrigger" : { "Description" : "Scale Up Policy Trigger", "Value" : { "Fn::Join" : [ "", [ "ScaleUpTrigger=", { "Ref" : "ScaleUpPolicy" } ]] } }, "ScaleDownTrigger" : { "Description" : "Scale Dowm Policy Trigger", "Value" : { "Fn::Join" : [ "", [ "ScaleDownTrigger=", { "Ref" : "ScaleDownPolicy" } ]] } } } }