Last active
December 28, 2015 14:39
-
-
Save sredhar/7516666 to your computer and use it in GitHub Desktop.
Mail
This file contains hidden or 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" : "2013-11-07", | |
"Description" : "AWS CloudFormation Template for mail. Creates a Auto Scaling group of web tier with load balancer, RDS and Elasticache cluster.", | |
"Parameters" : { | |
"KeyName" : { | |
"Description" : "Name of an existing Amazon EC2 KeyPair for SSH access to the Web Server", | |
"Type" : "String" | |
}, | |
"InstanceType" : { | |
"Description" : "Atmail WebServer EC2 instance type", | |
"Type" : "String", | |
"Default" : "m1.small", | |
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge", "m3.xlarge", "m3.2xlarge", "m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge", "hi1.4xlarge", "hs1.8xlarge"], | |
"ConstraintDescription" : "must be a valid EC2 instance type." | |
}, | |
"CacheNodeType" : { | |
"Default" : "cache.m1.small", | |
"Description" : "The compute and memory capacity of the nodes in the Cache Cluster", | |
"Type" : "String", | |
"AllowedValues" : [ "cache.m1.small", "cache.m1.large", "cache.m1.xlarge", "cache.m2.xlarge", "cache.m2.2xlarge", "cache.m2.4xlarge", "cache.c1.xlarge" ], | |
"ConstraintDescription" : "must select a valid Cache Node type." | |
}, | |
"NumberOfCacheNodes" : { | |
"Default": "1", | |
"Description" : "The number of Cache Nodes the Cache Cluster should have", | |
"Type": "Number", | |
"MinValue": "1", | |
"MaxValue": "10", | |
"ConstraintDescription" : "must be between 5 and 10." | |
} | |
}, | |
"Mappings" : { | |
"AWSInstanceType2Arch" : { | |
"t1.micro" : { "Arch" : "PV64" }, | |
"m1.small" : { "Arch" : "PV64" }, | |
"m1.medium" : { "Arch" : "PV64" }, | |
"m1.large" : { "Arch" : "PV64" }, | |
"m1.xlarge" : { "Arch" : "PV64" }, | |
"m3.xlarge" : { "Arch" : "PV64" }, | |
"m3.2xlarge" : { "Arch" : "PV64" } | |
}, | |
"AWSRegionArch2AMI" : { | |
"us-east-1" : { "PV64" : "ami-1624987f", "CLU64" : "ami-08249861", "GPU64" : "ami-02f54a6b" }, | |
"us-west-2" : { "PV64" : "ami-2a31bf1a", "CLU64" : "ami-2431bf14", "GPU64" : "NOT_YET_SUPPORTED" } | |
} | |
}, | |
"Resources" : { | |
"CacheCluster" : { | |
"Type": "AWS::ElastiCache::CacheCluster", | |
"Properties": { | |
"CacheNodeType" : { "Ref" : "CacheNodeType" }, | |
"CacheSecurityGroupNames" : [ { "Ref" : "CacheSecurityGroup" } ], | |
"Engine" : "memcached", | |
"NumCacheNodes" : { "Ref" : "NumberOfCacheNodes" } | |
} | |
}, | |
"CacheSecurityGroup": { | |
"Type": "AWS::ElastiCache::SecurityGroup", | |
"Properties": { | |
"Description" : "Lock cache down to Web Server access only" | |
} | |
}, | |
"CacheSecurityGroupIngress": { | |
"Type": "AWS::ElastiCache::SecurityGroupIngress", | |
"Properties": { | |
"CacheSecurityGroupName" : { "Ref" : "CacheSecurityGroup" }, | |
"EC2SecurityGroupName" : { "Ref" : "WebServerSecurityGroup" } | |
} | |
}, | |
"WebServerSecurityGroup" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"Properties" : { | |
"GroupDescription" : "Enable HTTP and SSH access", | |
"SecurityGroupIngress" : [ | |
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : { "Ref" : "SSHLocation"} }, | |
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"} | |
] | |
} | |
}, | |
"WebServerHost": { | |
"Type" : "AWS::EC2::Instance", | |
"Metadata" : { | |
"AWS::CloudFormation::Init" : { | |
"config" : { | |
"packages" : { | |
"yum" : { | |
"httpd" : [], | |
"gcc-c++" : [], | |
"php" : [], | |
"php-pear" : [] | |
} | |
}, | |
"commands" : { | |
"00_install_memcached_client" : { | |
"command" : "pecl install https://s3.amazonaws.com/elasticache-downloads/ClusterClient/PHP/latest-64bit" | |
}, | |
"01_enable_auto_discovery" : { | |
"command" : "echo 'extension=amazon-elasticache-cluster-client.so' > /etc/php.d/memcached.ini" | |
} | |
}, | |
"services" : { | |
"sysvinit" : { | |
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }, | |
"sendmail" : { "enabled" : "false", "ensureRunning" : "false" } | |
} | |
} | |
} | |
} | |
}, | |
"Properties": { | |
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, | |
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ]}]}, | |
"InstanceType" : { "Ref" : "InstanceType" }, | |
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ], | |
"KeyName" : { "Ref" : "KeyName" }, | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ | |
"#!/bin/bash -v\n", | |
"yum update -y aws-cfn-bootstrap\n", | |
"# Setup the PHP sample application\n", | |
"/opt/aws/bin/cfn-init ", | |
" --stack ", { "Ref" : "AWS::StackName" }, | |
" --resource WebServerHost ", | |
" --region ", { "Ref" : "AWS::Region" }, "\n", | |
"# Signal the status of cfn-init\n", | |
"/opt/aws/bin/cfn-signal -e $? '", { "Ref" : "WebServerWaitHandle" }, "'\n" | |
]]}} | |
} | |
}, | |
"WebServerWaitHandle" : { | |
"Type" : "AWS::CloudFormation::WaitConditionHandle" | |
}, | |
"WebServerWaitCondition" : { | |
"Type" : "AWS::CloudFormation::WaitCondition", | |
"DependsOn" : "WebServerHost", | |
"Properties" : { | |
"Handle" : {"Ref" : "WebServerWaitHandle"}, | |
"Timeout" : "300" | |
} | |
} | |
}, | |
"Outputs" : { | |
"WebsiteURL" : { | |
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServerHost", "PublicDnsName" ]} ]] }, | |
"Description" : "Application URL" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment