Skip to content

Instantly share code, notes, and snippets.

@jfryman jfryman/cf.json
Last active Dec 21, 2015

Embed
What would you like to do?
CloudFormation Example
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Role: Renderer. Amazon CloudFormation Template",
"Parameters": {
"AMI":{
"Description":"The AMI You want to use",
"Type":"String",
"Default":"ami-8fc476e6"
},
"InstanceType": {
"Description": "Renderer Server EC2 Instance Type",
"Type": "String",
"Default": "c1.xlarge",
"AllowedValues": ["c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge"],
"ConstraintDescription": "must be a valid EC2 instance type"
},
"KeyName": {
"Description": "Name of an existing EC2 Keypair to enable access to the machine",
"Type": "String",
"Default": "sw-production-east-va"
}
},
"Resources": {
"RendererServerGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": { "Fn::GetAZs": "" },
"LaunchConfigurationName": { "Ref": "LaunchConfig" },
"MinSize": "2",
"MaxSize": "16",
"Tags": [
{ "Key": "Environment", "Value": "Production", "PropagateAtLaunch": "true" },
{ "Key": "Role", "Value": "renderer", "PropagateAtLaunch": "true" }
]
}
},
"LaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"KeyName": { "Ref": "KeyName" },
"ImageId" : {"Ref":"AMI"},
"SecurityGroups": [ { "Ref": "InstanceSecurityGroup" }],
"InstanceType": { "Ref": "InstanceType" }
}
},
"RendererServerScaleUpPolicy" : {
"Type" : "AWS::AutoScaling::ScalingPolicy",
"Properties" : {
"AdjustmentType" : "ChangeInCapacity",
"AutoScalingGroupName" : { "Ref" : "RendererServerGroup" },
"Cooldown" : "300",
"ScalingAdjustment" : "6"
}
},
"RendererServerScaleDownPolicy" : {
"Type" : "AWS::AutoScaling::ScalingPolicy",
"Properties" : {
"AdjustmentType" : "ChangeInCapacity",
"AutoScalingGroupName" : { "Ref" : "RendererServerGroup" },
"Cooldown" : "300",
"ScalingAdjustment" : "-1"
}
},
"ScaleUpAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Hit it with a hammer",
"MetricName": "Prod-VideoRenderQueueLength",
"Namespace": "DatCompany",
"Statistic": "Average",
"Period": "60",
"EvaluationPeriods": "2",
"Threshold": "60",
"AlarmActions": [ { "Ref": "RendererServerScaleUpPolicy" } ],
"ComparisonOperator": "GreaterThanThreshold"
}
},
"ScaleDownAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Simmer Down",
"MetricName": "Prod-VideoRenderQueueLength",
"Namespace": "DatCompany",
"Statistic": "Average",
"Period": "60",
"EvaluationPeriods": "5",
"Threshold": "30",
"AlarmActions": [ { "Ref": "RendererServerScaleDownPolicy" } ],
"ComparisonOperator": "LessThanThreshold"
}
},
"InstanceSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH access to the configured server",
"SecurityGroupIngress" : [
{ "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "0.0.0.0/0" }
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.