Created
April 26, 2019 00:51
-
-
Save alekseybobkov/6c6877a44507c6efccc17484d835a968 to your computer and use it in GitHub Desktop.
CloudFormation template for October CMS demo AWS infrastructure, Part 1: https://octobercms.com/blog/post/running-october-aws-part-1
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": "2010-09-09", | |
| "Description": "October CMS demo infrastructure.", | |
| "Parameters": { | |
| "KeyName": { | |
| "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance", | |
| "Type": "AWS::EC2::KeyPair::KeyName", | |
| "ConstraintDescription": "must be the name of an existing EC2 KeyPair." | |
| }, | |
| "StagingInstanceType": { | |
| "Description": "Staging instance EC2 instance type", | |
| "Type": "String", | |
| "Default": "t2.micro", | |
| "AllowedValues": ["t1.micro", "t2.nano", "t2.micro", "t2.small", "t2.medium", "t2.large"], | |
| "ConstraintDescription": "must be a valid EC2 instance type." | |
| }, | |
| "DBName": { | |
| "Default": "MyDatabase", | |
| "Description": "MySQL 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." | |
| }, | |
| "DBUser": { | |
| "NoEcho": "true", | |
| "Description": "Username for MySQL database access", | |
| "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": { | |
| "NoEcho": "true", | |
| "Description": "Password MySQL database access", | |
| "Type": "String", | |
| "MinLength": "8", | |
| "MaxLength": "41", | |
| "AllowedPattern": "[a-zA-Z0-9]*", | |
| "ConstraintDescription": "must contain only alphanumeric characters." | |
| }, | |
| "DBClass": { | |
| "Description": "Database instance class", | |
| "Type": "String", | |
| "Default": "db.t2.micro", | |
| "AllowedValues": ["db.t2.micro", "db.t2.small", "db.t2.medium", "db.t2.large"], | |
| "ConstraintDescription": "must be a valid RDS instance class." | |
| }, | |
| "DBAllocatedStorage": { | |
| "Default": 100, | |
| "Description": "The size of the database (Gb)", | |
| "Type": "Number", | |
| "MinValue": 5, | |
| "MaxValue": 1024, | |
| "ConstraintDescription": "must be between 5 and 1024Gb." | |
| }, | |
| "StagingImageId": { | |
| "Type": "AWS::EC2::Image::Id", | |
| "ConstraintDescription": "must be a valid AMI identifier." | |
| } | |
| }, | |
| "Resources": { | |
| "VPC": { | |
| "Type": "AWS::EC2::VPC", | |
| "Properties": { | |
| "CidrBlock": "10.0.0.0/16", | |
| "EnableDnsSupport": true, | |
| "EnableDnsHostnames": true, | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS VPC" | |
| } | |
| ] | |
| } | |
| }, | |
| "PublicSubnet": { | |
| "Type": "AWS::EC2::Subnet", | |
| "Properties": { | |
| "VpcId": { | |
| "Ref": "VPC" | |
| }, | |
| "MapPublicIpOnLaunch": "true", | |
| "CidrBlock": "10.0.1.0/24", | |
| "AvailabilityZone": "us-west-2a", | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS Public Subnet" | |
| } | |
| ] | |
| } | |
| }, | |
| "DBSubnet1": { | |
| "Type": "AWS::EC2::Subnet", | |
| "Properties": { | |
| "AvailabilityZone": { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::GetAZs": "" | |
| } | |
| ] | |
| }, | |
| "CidrBlock": "10.0.3.0/24", | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS DB Subnet 1" | |
| } | |
| ], | |
| "VpcId": { | |
| "Ref": "VPC" | |
| } | |
| } | |
| }, | |
| "DBSubnet2": { | |
| "Type": "AWS::EC2::Subnet", | |
| "Properties": { | |
| "AvailabilityZone": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::GetAZs": "" | |
| } | |
| ] | |
| }, | |
| "CidrBlock": "10.0.4.0/24", | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS DB Subnet 2" | |
| } | |
| ], | |
| "VpcId": { | |
| "Ref": "VPC" | |
| } | |
| } | |
| }, | |
| "DBSubnetGroup": { | |
| "Properties": { | |
| "DBSubnetGroupDescription": "October CMS subnets for RDS", | |
| "SubnetIds": [{ | |
| "Ref": "DBSubnet1" | |
| }, | |
| { | |
| "Ref": "DBSubnet2" | |
| } | |
| ] | |
| }, | |
| "Type": "AWS::RDS::DBSubnetGroup" | |
| }, | |
| "InternetGateway": { | |
| "Type": "AWS::EC2::InternetGateway", | |
| "Properties": { | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS Gateway" | |
| } | |
| ] | |
| } | |
| }, | |
| "AttachGateway": { | |
| "Type": "AWS::EC2::VPCGatewayAttachment", | |
| "Properties": { | |
| "VpcId": { | |
| "Ref": "VPC" | |
| }, | |
| "InternetGatewayId": { | |
| "Ref": "InternetGateway" | |
| } | |
| } | |
| }, | |
| "InternetAccessRouteTable": { | |
| "Type": "AWS::EC2::RouteTable", | |
| "Properties": { | |
| "VpcId": { | |
| "Ref": "VPC" | |
| }, | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS VPC Internet Access" | |
| } | |
| ] | |
| } | |
| }, | |
| "InternetAccessRoute": { | |
| "Type": "AWS::EC2::Route", | |
| "DependsOn": "AttachGateway", | |
| "Properties": { | |
| "RouteTableId": { | |
| "Ref": "InternetAccessRouteTable" | |
| }, | |
| "DestinationCidrBlock": "0.0.0.0/0", | |
| "GatewayId": { | |
| "Ref": "InternetGateway" | |
| } | |
| } | |
| }, | |
| "PublicSubnetRouteTableAssociation": { | |
| "Type": "AWS::EC2::SubnetRouteTableAssociation", | |
| "Properties": { | |
| "SubnetId": { | |
| "Ref": "PublicSubnet" | |
| }, | |
| "RouteTableId": { | |
| "Ref": "InternetAccessRouteTable" | |
| } | |
| } | |
| }, | |
| "WebServerSecurityGroup": { | |
| "Type": "AWS::EC2::SecurityGroup", | |
| "Properties": { | |
| "GroupDescription": "Enable SSH access via ports 80 and 22", | |
| "SecurityGroupIngress": [{ | |
| "IpProtocol": "tcp", | |
| "FromPort": "22", | |
| "ToPort": "22", | |
| "CidrIp": "0.0.0.0/0" | |
| }, | |
| { | |
| "IpProtocol": "tcp", | |
| "FromPort": "80", | |
| "ToPort": "80", | |
| "CidrIp": "0.0.0.0/0" | |
| } | |
| ], | |
| "VpcId": { | |
| "Ref": "VPC" | |
| }, | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS Web Server SG" | |
| } | |
| ] | |
| } | |
| }, | |
| "MountTargetSecurityGroup": { | |
| "Type": "AWS::EC2::SecurityGroup", | |
| "Properties": { | |
| "VpcId": { | |
| "Ref": "VPC" | |
| }, | |
| "GroupDescription": "Security group for EFS mount target", | |
| "SecurityGroupIngress": [{ | |
| "IpProtocol": "tcp", | |
| "FromPort": "2049", | |
| "ToPort": "2049", | |
| "SourceSecurityGroupId": { | |
| "Fn::GetAtt": [ | |
| "WebServerSecurityGroup", | |
| "GroupId" | |
| ] | |
| } | |
| }], | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS EFS mount target SG" | |
| } | |
| ] | |
| } | |
| }, | |
| "DBSecurityGroup": { | |
| "Type": "AWS::EC2::SecurityGroup", | |
| "Properties": { | |
| "GroupDescription": "Open database for access from web servers", | |
| "VpcId": { | |
| "Ref": "VPC" | |
| }, | |
| "SecurityGroupIngress": [{ | |
| "IpProtocol": "tcp", | |
| "FromPort": "3306", | |
| "ToPort": "3306", | |
| "SourceSecurityGroupId": { | |
| "Fn::GetAtt": [ | |
| "WebServerSecurityGroup", | |
| "GroupId" | |
| ] | |
| } | |
| }], | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS database SG" | |
| } | |
| ] | |
| } | |
| }, | |
| "FileSystem": { | |
| "Type": "AWS::EFS::FileSystem", | |
| "Properties": { | |
| "PerformanceMode": "generalPurpose", | |
| "FileSystemTags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS file data" | |
| } | |
| ] | |
| } | |
| }, | |
| "DBInstance": { | |
| "Type": "AWS::RDS::DBInstance", | |
| "Properties": { | |
| "DBName": { | |
| "Ref": "DBName" | |
| }, | |
| "MasterUsername": { | |
| "Ref": "DBUser" | |
| }, | |
| "MasterUserPassword": { | |
| "Ref": "DBPassword" | |
| }, | |
| "Engine": "MySQL", | |
| "DBInstanceClass": { | |
| "Ref": "DBClass" | |
| }, | |
| "AllocatedStorage": { | |
| "Ref": "DBAllocatedStorage" | |
| }, | |
| "StorageType": "gp2", | |
| "VPCSecurityGroups": [{ | |
| "Fn::GetAtt": ["DBSecurityGroup", "GroupId"] | |
| }], | |
| "DBSubnetGroupName": { | |
| "Ref": "DBSubnetGroup" | |
| }, | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS MySQL" | |
| } | |
| ] | |
| } | |
| }, | |
| "MountTarget": { | |
| "Type": "AWS::EFS::MountTarget", | |
| "Properties": { | |
| "FileSystemId": { | |
| "Ref": "FileSystem" | |
| }, | |
| "SubnetId": { | |
| "Ref": "PublicSubnet" | |
| }, | |
| "SecurityGroups": [{ | |
| "Ref": "MountTargetSecurityGroup" | |
| }] | |
| } | |
| }, | |
| "StagingInstance": { | |
| "Type": "AWS::EC2::Instance", | |
| "Properties": { | |
| "ImageId": { | |
| "Ref": "StagingImageId" | |
| }, | |
| "KeyName": { | |
| "Ref": "KeyName" | |
| }, | |
| "InstanceType": { | |
| "Ref": "StagingInstanceType" | |
| }, | |
| "NetworkInterfaces": [{ | |
| "AssociatePublicIpAddress": "true", | |
| "DeviceIndex": "0", | |
| "GroupSet": [{ | |
| "Ref": "WebServerSecurityGroup" | |
| }], | |
| "SubnetId": { | |
| "Ref": "PublicSubnet" | |
| } | |
| }], | |
| "Tags": [{ | |
| "Key": "Application", | |
| "Value": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Key": "Name", | |
| "Value": "October CMS Staging Instance" | |
| } | |
| ] | |
| }, | |
| "DependsOn": ["FileSystem", "MountTarget"] | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment