Created
January 14, 2014 06:25
-
-
Save chhibber/8413968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "US East Development Staging :: ELBs, RDS, DNS, WWWs, and Workers :: AZ-1B and AZ-1C", | |
"Parameters" : { | |
"AGInstanceType" : { | |
"Type" : "String", | |
"Description" : "Instance Type for autoscaling group", | |
"Default": "m1.medium" | |
}, | |
"IMAGEID" : { | |
"Type": "String", | |
"Description": "Instance ID", | |
"Default": "ami-3275ee5b" | |
}, | |
"VPC" : { | |
"Type" : "String", | |
"Description" : "VPC Id of your existing Virtual Private Cloud (VPC)", | |
"Default": "vpc-48f08c24" | |
}, | |
"PublicSubnet1" : { | |
"Type" : "String", | |
"Description" : "Subnet Id of an existing public subnet (us-east-1b) in your Virtual Private Cloud (VPC)", | |
"Default": "subnet-2cf08c40" | |
}, | |
"PublicSubnet2" : { | |
"Type" : "String", | |
"Description" : "Subnet Id of an existing public subnet (us-east-1c) in your Virtual Private Cloud (VPC)", | |
"Default": "subnet-32f08c5e" | |
}, | |
"PrivateSubnet1" : { | |
"Type" : "String", | |
"Description" : "Subnet Id of an existing subnet (us-east-1b) in your Virtual Private Cloud (VPC)", | |
"Default": "subnet-70f18d1c" | |
}, | |
"PrivateSubnet2" : { | |
"Type" : "String", | |
"Description" : "Subnet Id of an existing subnet (us-east-1c) in your Virtual Private Cloud (VPC)", | |
"Default": "subnet-5df18d31" | |
}, | |
"SSLCertificateName" : { | |
"Type": "String", | |
"Description": "FOOBAR Wildcard Cert", | |
"Default": "startDOTFOOBARDOTcom" | |
}, | |
"ResourceAccountID" :{ | |
"Type": "String", | |
"Description": "Resource Account ID", | |
"Default": "129486710928" | |
}, | |
"SGsalt" : { | |
"Type" : "String", | |
"Description" : "Security Group ID for Salt", | |
"Default": "sg-XXXXXXX" | |
}, | |
"SGwww" : { | |
"Type" : "String", | |
"Description" : "Security Group ID for WWW", | |
"Default": "sg-xxxxxx" | |
}, | |
"SGrds" : { | |
"Type" : "String", | |
"Description" : "Security Group ID for RDS", | |
"Default": "sg-xxxxxxx" | |
}, | |
"SGworker" : { | |
"Type" : "String", | |
"Description" : "Worker Security group ID", | |
"Default": "sg-xxxxxxxx" | |
}, | |
"DBName": { | |
"Default": "FOOBAR", | |
"Description" : "The database name", | |
"Type": "String", | |
"MinLength": "1", | |
"MaxLength": "64", | |
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", | |
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." | |
}, | |
"DBUsername": { | |
"Default": "FOOBAR", | |
"NoEcho": "true", | |
"Description" : "The database admin account username", | |
"Type": "String", | |
"MinLength": "1", | |
"MaxLength": "16", | |
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", | |
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." | |
}, | |
"DBPassword": { | |
"Default": "APASSSSSWORD", | |
"NoEcho": "true", | |
"Description" : "The database admin account password", | |
"Type": "String", | |
"MinLength": "1", | |
"MaxLength": "41", | |
"AllowedPattern" : "[a-zA-Z0-9]*", | |
"ConstraintDescription" : "must contain only alphanumeric characters." | |
}, | |
"DBClass" : { | |
"Default" : "db.m1.large", | |
"Description" : "Database instance class", | |
"Type" : "String", | |
"AllowedValues" : [ "db.m1.small", "db.m1.large", "db.m1.xlarge", "db.m2.xlarge", "db.m2.2xlarge", "db.m2.4xlarge" ], | |
"ConstraintDescription" : "must select a valid database instance type." | |
}, | |
"DBAllocatedStorage" : { | |
"Default": "5", | |
"Description" : "The size of the database (Gb)", | |
"Type": "Number", | |
"MinValue": "5", | |
"MaxValue": "1024", | |
"ConstraintDescription" : "must be between 5 and 1024Gb." | |
}, | |
"DBSnapshot" : { | |
"Default": "staging", | |
"Description" : "Snapshot to load DB from", | |
"Type": "String" | |
} | |
}, | |
"Resources" : { | |
"SGELBwww" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"Properties" : | |
{ | |
"VpcId" : { "Ref" : "VPC" }, | |
"GroupDescription" : "Web Server - Allow access to port 80 and 443", | |
"SecurityGroupIngress" : [ { | |
"IpProtocol" : "tcp", | |
"FromPort" : "80", | |
"ToPort" : "80", | |
"CidrIp" : "0.0.0.0/0" | |
}, { | |
"IpProtocol" : "tcp", | |
"FromPort" : "443", | |
"ToPort" : "443", | |
"CidrIp" : "0.0.0.0/0" | |
} ] | |
} | |
}, | |
"ELBwww" : { | |
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer", | |
"Properties" : { | |
"SecurityGroups" : [ { "Ref" : "SGELBwww" } ], | |
"Subnets" : [ { "Ref" : "PublicSubnet1" }, { "Ref" : "PublicSubnet2" } ], | |
"Listeners" : [ { | |
"LoadBalancerPort" : "80", | |
"InstancePort" : "80", "Protocol" : "HTTP" | |
}, { | |
"LoadBalancerPort" : "443", | |
"InstanceProtocol" : "HTTPS", | |
"InstancePort" : "443", | |
"Protocol" : "HTTPS", | |
"SSLCertificateId" : { "Fn::Join" : [ "", [ "arn:aws:iam::", { "Ref" : "ResourceAccountID" }, ":server-certificate/", { "Ref" : "SSLCertificateName" } ] ] } | |
}], | |
"HealthCheck" : { | |
"Target" : "HTTPS:443/status.json", | |
"HealthyThreshold" : "3", | |
"UnhealthyThreshold" : "5", | |
"Interval" : "20", | |
"Timeout" : "5" | |
} | |
} | |
}, | |
"DBSubnetGroup" : { | |
"Type" : "AWS::RDS::DBSubnetGroup", | |
"Properties" : { | |
"DBSubnetGroupDescription" : "Subnets available for the RDS DB Instance", | |
"SubnetIds" : [ { "Ref" : "PrivateSubnet1" }, { "Ref" : "PrivateSubnet2" }] | |
} | |
}, | |
"DBParamaterGroupMySQL56" : { | |
"Type": "AWS::RDS::DBParameterGroup", | |
"Properties" : { | |
"Description" : "DB Params for 5.6", | |
"Family" : "MySQL5.6", | |
"Parameters" : { | |
"max_allowed_packet" : "16777216", | |
"ft_min_word_len" : "2", | |
"character_set_client" : "utf8", | |
"character_set_connection" : "utf8", | |
"character_set_database" : "utf8", | |
"character_set_filesystem" : "binary", | |
"character_set_results" : "utf8", | |
"character_set_server" : "utf8", | |
"collation_connection" : "utf8_general_ci", | |
"collation_server" : "utf8_general_ci" | |
} | |
} | |
}, | |
"DB" : { | |
"Type" : "AWS::RDS::DBInstance", | |
"Properties" : { | |
"AllocatedStorage" : { "Ref" : "DBAllocatedStorage" }, | |
"DBInstanceClass" : { "Ref" : "DBClass" }, | |
"DBSnapshotIdentifier" : { "Ref" : "DBSnapshot" }, | |
"Engine" : "MySQL", | |
"EngineVersion" : "5.6", | |
"MasterUsername" : { "Ref" : "DBUsername" } , | |
"MasterUserPassword" : { "Ref" : "DBPassword" }, | |
"DBSubnetGroupName" : { "Ref" : "DBSubnetGroup" }, | |
"VPCSecurityGroups" : [ { "Ref" : "SGrds" } ], | |
"MultiAZ" : "true", | |
"DBParameterGroupName" : { "Ref" : "DBParamaterGroupMySQL56" } | |
}, | |
"DeletionPolicy" : "Snapshot" | |
}, | |
"ASGwww" : { | |
"Type" : "AWS::AutoScaling::AutoScalingGroup", | |
"Properties" : { | |
"AvailabilityZones" : ["us-east-1b","us-east-1c"], | |
"VPCZoneIdentifier" : [ { "Ref" : "PrivateSubnet1" }, { "Ref" : "PrivateSubnet2" }], | |
"LaunchConfigurationName" : { "Ref" : "LaunchConfig1" }, | |
"MinSize" : "1", | |
"MaxSize" : "1", | |
"LoadBalancerNames" : [ { "Ref" : "ELBwww" } ], | |
"Tags" : [ | |
{ "Key" : "Role", "Value" : "www", "PropagateAtLaunch" : true }, | |
{ "Key" : "Roles", "Value" : "web,app", "PropagateAtLaunch" : true }, | |
{ "Key" : "Env", "Value" : "staging", "PropagateAtLaunch" : true }, | |
{ "Key" : "Primary", "Value" : "true", "PropagateAtLaunch" : true }, | |
{ "Key" : "Roles", "Value" : "web,app,cron,resque,resque-scheduler,god", "PropagateAtLaunch" : true }, | |
{ "Key" : "MonitoredServices", "Value" : "resque,resque-scheduler", "PropagateAtLaunch" : true } | |
] | |
} | |
}, | |
"LaunchConfig1" : { | |
"Type" : "AWS::AutoScaling::LaunchConfiguration", | |
"Properties" : { | |
"KeyName" : "test-env", | |
"ImageId" : { "Ref" : "IMAGEID"}, | |
"IamInstanceProfile": "FOOBAR-ec2-default-role", | |
"SecurityGroups" : [ { "Ref" : "SGwww" } ], | |
"InstanceType" : { "Ref" : "AGInstanceType" }, | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash\n", | |
"yum -y update\n", | |
"sleep 3\n", | |
"yum -y update\n", | |
"easy_install --upgrade boto\n", | |
"python << PY\n", | |
"import os\n", | |
"import boto\n", | |
"from boto.s3.key import Key\n", | |
"s3 = boto.connect_s3()\n", | |
"bucket = s3.get_bucket('FOOBAR.devops')\n", | |
"for key in bucket.list('cloud-init'):\n", | |
" file = key.name.encode('utf-8').split('/')[-1]\n", | |
" if file:\n", | |
" print 'Dowloading' + file\n", | |
" key.get_contents_to_filename(file)\n", | |
"PY\n", | |
"chmod u+x ./boot-strap1.sh\n", | |
"./boot-strap1.sh\n" | |
]]}} | |
} | |
}, | |
"ASGWorker" : { | |
"Type" : "AWS::AutoScaling::AutoScalingGroup", | |
"Properties" : { | |
"AvailabilityZones" : ["us-east-1b","us-east-1c"], | |
"VPCZoneIdentifier" : [ { "Ref" : "PrivateSubnet1" }, { "Ref" : "PrivateSubnet2" } ], | |
"LaunchConfigurationName" : { "Ref" : "LaunchConfigWorker" }, | |
"MinSize" : "1", | |
"MaxSize" : "1", | |
"Tags" : [ | |
{ "Key" : "Role", "Value" : "worker", "PropagateAtLaunch" : true }, | |
{ "Key" : "Roles", "Value" : "app,db,resque,god", "PropagateAtLaunch" : true }, | |
{ "Key" : "MonitoredServices", "Value" : "resque,resque-scheduler", "PropagateAtLaunch" : true }, | |
{ "Key" : "Env", "Value" : "staging", "PropagateAtLaunch" : true } | |
] | |
}, | |
"DependsOn" : "DB" | |
}, | |
"LaunchConfigWorker" : { | |
"Type" : "AWS::AutoScaling::LaunchConfiguration", | |
"Properties" : { | |
"KeyName" : "test-env", | |
"ImageId" : { "Ref" : "IMAGEID"}, | |
"IamInstanceProfile": "FOOBAR-ec2-default-role", | |
"SecurityGroups" : [ { "Ref" : "SGworker" } ], | |
"InstanceType" : { "Ref" : "AGInstanceType" }, | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash\n", | |
"yum -y update\n", | |
"sleep 3\n", | |
"yum -y update\n", | |
"easy_install --upgrade boto\n", | |
"python << PY\n", | |
"import os\n", | |
"import boto\n", | |
"from boto.s3.key import Key\n", | |
"s3 = boto.connect_s3()\n", | |
"bucket = s3.get_bucket('FOOBAR.devops')\n", | |
"for key in bucket.list('cloud-init'):\n", | |
" file = key.name.encode('utf-8').split('/')[-1]\n", | |
" if file:\n", | |
" print 'Dowloading' + file\n", | |
" key.get_contents_to_filename(file)\n", | |
"PY\n", | |
"chmod u+x ./boot-strap1.sh\n", | |
"./boot-strap1.sh\n" | |
]]}} | |
} | |
}, | |
"ELBwwwDNSRecord" : { | |
"Type" : "AWS::Route53::RecordSet", | |
"Properties" : { | |
"HostedZoneId" : "/hostedzone/Z12F92KMETYU0Z", | |
"Comment" : "CNAME for my WWW.", | |
"Name" : "staging.FOOBAR.com.", | |
"Type" : "CNAME", | |
"TTL" : "900", | |
"ResourceRecords" : [ | |
{"Fn::GetAtt":["ELBwww","DNSName"]} | |
] | |
} | |
}, | |
"ELBRDSDNSRecord" : { | |
"Type" : "AWS::Route53::RecordSet", | |
"Properties" : { | |
"HostedZoneId" : "/hostedzone/Z12F92KMETYU0Z", | |
"Comment" : "CNAME for my WWW.", | |
"Name" : "staging-rds.FOOBAR.com.", | |
"Type" : "CNAME", | |
"TTL" : "900", | |
"ResourceRecords" : [ | |
{"Fn::GetAtt": ["DB","Endpoint.Address"]} | |
] | |
} | |
} | |
}, | |
"Outputs" : { | |
"RDSEndpoint": { | |
"Description" : "RDS Endpoint for FOOBAR Database", | |
"Value" : {"Fn::GetAtt": ["DB","Endpoint.Address"]} | |
}, | |
"ELBwwwDNS": { | |
"Description" : "DNS for WWW ELB", | |
"Value" : {"Fn::GetAtt": ["ELBwww","DNSName"]} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment