Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
867 lines (772 sloc) 26.5 KB
DEPRECATED WARNING!
This file is deprecated now. Use the .yml file in this directory instead.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Custom VPC and Multi-AZ stack for Drupal 7 with MySQL DB, redis and EFS file storage. This stack uses a realistic example Drupal site, hosted on Github and Docker hub. For more information see https://github.com/karelbemelmans/drupal7-on-aws/",
"Parameters": {
"KeyPairName": {
"Description": "The key pair name to connect to the instances",
"Type": "AWS::EC2::KeyPair::KeyName"
},
"WebServerInstanceType": {
"Description": "WebServer EC2 instance type",
"Type": "String",
"Default": "t2.small",
"AllowedValues": ["t2.micro", "t2.small"],
"ConstraintDescription": "must be a t2.micro or t2.small instance type"
},
"VpcCidrBlock": {
"Description": "VPC CIDR block",
"Type": "String",
"Default": "10.42.0.0/16"
},
"PublicSubnetOneCidr": {
"Description": "The CIDR ranges of the public subnets",
"Type": "String",
"Default": "10.42.0.0/18"
},
"PublicSubnetTwoCidr": {
"Description": "The CIDR ranges of the public subnets",
"Type": "String",
"Default": "10.42.64.0/18"
},
"PrivateSubnetOneCidr": {
"Description": "The CIDR ranges of the private subnets",
"Type": "String",
"Default": "10.42.128.0/18"
},
"PrivateSubnetTwoCidr": {
"Description": "The CIDR ranges of the private subnets",
"Type": "String",
"Default": "10.42.192.0/18"
},
"DbName": {
"Description": "The name of the database",
"Type": "String",
"MinLength": "4",
"MaxLength": "16",
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
},
"DbMasterUsername": {
"Description": "The Master username for the Drupal DB",
"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."
},
"DbMasterPassword": {
"Description": "The Master password for the Drupal DB",
"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."
},
"WebServerCapacity": {
"Default": "2",
"Description" : "The initial number of WebServer instances",
"Type": "Number",
"MinValue": "0",
"MaxValue": "10",
"ConstraintDescription" : "must be between 0 and 10 EC2 instances."
},
"DBClass" : {
"Description" : "Database instance class",
"Type" : "String",
"Default" : "db.t2.small",
"AllowedValues" : [ "db.t1.micro", "db.m1.small", "db.m1.medium", "db.m1.large", "db.m1.xlarge", "db.m2.xlarge", "db.m2.2xlarge", "db.m2.4xlarge", "db.m3.medium", "db.m3.large", "db.m3.xlarge", "db.m3.2xlarge", "db.m4.large", "db.m4.xlarge", "db.m4.2xlarge", "db.m4.4xlarge", "db.m4.10xlarge", "db.r3.large", "db.r3.xlarge", "db.r3.2xlarge", "db.r3.4xlarge", "db.r3.8xlarge", "db.m2.xlarge", "db.m2.2xlarge", "db.m2.4xlarge", "db.cr1.8xlarge", "db.t2.micro", "db.t2.small", "db.t2.medium", "db.t2.large"]
,
"ConstraintDescription" : "must select a valid database instance type."
},
"MultiAZDatabase": {
"Default": "false",
"Description" : "Create a Multi-AZ MySQL Amazon RDS database instance. This will take a while to create.",
"Type": "String",
"AllowedValues" : [ "true", "false" ],
"ConstraintDescription" : "must be either true or false."
},
"DBAllocatedStorage" : {
"Default": "5",
"Description" : "The size of the database (Gb)",
"Type": "Number",
"MinValue": "5",
"MaxValue": "1024",
"ConstraintDescription" : "must be between 5 and 1024Gb."
},
"MountPoint" : {
"Description" : "The Linux mount point for the EFS volume",
"Type": "String",
"MinLength": "1",
"Default": "drupalSharedFiles"
},
"DockerImage": {
"Description": "Name of the Docker image that contains the Drupal 7 website.",
"Type": "String",
"Default": "karelbemelmans/d7-docker-v1"
},
"SyslogDestination": {
"Description": "Syslog destionation. Synthax: tcp://host:port",
"Type": "String"
},
"SslCertificateId": {
"Description": "The SSL certificate id (arn) for HTTPS on the ELB",
"Type": "String"
}
},
"Mappings": {
"AmazonMachineImages": {
"eu-west-1": {
"64": "ami-b0ac25c3",
"Description": "Amazon Linux AMI 2016.03.1 (HVM), SSD Volume Type, eu-west-1"
},
"us-east-1": {
"64": "ami-f5f41398",
"Description": "Amazon Linux AMI 2016.03.1 (HVM), SSD Volume Type, us-east-1"
},
"us-west-1": {
"64": "ami-6e84fa0e",
"Description": "Amazon Linux AMI 2016.03.1 (HVM), SSD Volume Type, us-west-1"
},
"us-west-2": {
"64": "ami-d0f506b0",
"Description": "Amazon Linux AMI 2016.03.1 (HVM), SSD Volume Type, us-west-2"
}
}
},
"Outputs" : {
"WebsiteURL" : {
"Description" : "URL for newly created Drupal stack",
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "DrupalWebServerElasticLoadBalancer", "DNSName" ]}]] }
}
},
"Resources": {
"MountTargetSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"VpcId": { "Ref": "VPC" },
"GroupDescription": "Security group for Drupal mount target",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "2049",
"ToPort": "2049",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"SharedFileSystem": {
"Type": "AWS::EFS::FileSystem",
"Properties": {
"FileSystemTags": [
{
"Key": "Name",
"Value": "Drupal Shared Filesystem"
}
]
}
},
"MountTargetPrivateSubnetOne": {
"Type": "AWS::EFS::MountTarget",
"Properties": {
"FileSystemId": { "Ref": "SharedFileSystem" },
"SubnetId": { "Ref": "PrivateSubnetOne" },
"SecurityGroups": [ { "Ref": "MountTargetSecurityGroup" } ]
}
},
"MountTargetPrivateSubnetTwo": {
"Type": "AWS::EFS::MountTarget",
"Properties": {
"FileSystemId": { "Ref": "SharedFileSystem" },
"SubnetId": { "Ref": "PrivateSubnetTwo" },
"SecurityGroups": [ { "Ref": "MountTargetSecurityGroup" } ]
}
},
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"CidrBlock": { "Ref": "VpcCidrBlock" },
"Tags": [{
"Key": "Name",
"Value": "Drupal 7 VPC"
}]
}
},
"PublicSubnetOne": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": { "Ref": "VPC" },
"MapPublicIpOnLaunch": true,
"CidrBlock": { "Ref": "PublicSubnetOneCidr" },
"AvailabilityZone": {
"Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ]
},
"Tags": [{
"Key": "Name",
"Value": "Public Subnet #1"
}]
}
},
"PublicSubnetTwo": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": { "Ref": "VPC" },
"MapPublicIpOnLaunch": true,
"CidrBlock": { "Ref": "PublicSubnetTwoCidr" },
"AvailabilityZone": {
"Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ]
},
"Tags": [{
"Key": "Name",
"Value": "Public Subnet #2"
}]
}
},
"PrivateSubnetOne": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": { "Ref": "VPC" },
"MapPublicIpOnLaunch": false,
"CidrBlock": { "Ref": "PrivateSubnetOneCidr" },
"AvailabilityZone": {
"Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ]
},
"Tags": [{
"Key": "Name",
"Value": "Private Subnet #1"
}]
}
},
"PrivateSubnetTwo": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": { "Ref": "VPC" },
"MapPublicIpOnLaunch": false,
"CidrBlock": { "Ref": "PrivateSubnetTwoCidr" },
"AvailabilityZone": {
"Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ]
},
"Tags": [{
"Key": "Name",
"Value": "Private Subnet #2"
}]
}
},
"PublicSubnetOneRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": { "Ref": "PublicSubnetOne" },
"RouteTableId": { "Ref": "PublicRouteTable" }
}
},
"PublicSubnetTwoRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": { "Ref": "PublicSubnetTwo" },
"RouteTableId": { "Ref": "PublicRouteTable" }
}
},
"PrivateSubnetOneRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": { "Ref": "PrivateSubnetOne" },
"RouteTableId": { "Ref": "PrivateRouteTableOne" }
}
},
"PrivateSubnetTwoRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": { "Ref": "PrivateSubnetTwo" },
"RouteTableId": { "Ref": "PrivateRouteTableTwo" }
}
},
"PrivateRouteToInternetOne": {
"DependsOn": [ "PrivateRouteTableOne", "NATGatewayOne" ],
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": { "Ref": "PrivateRouteTableOne" },
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": { "Ref": "NATGatewayOne" }
}
},
"PrivateRouteToInternetTwo": {
"DependsOn": [ "PrivateRouteTableTwo", "NATGatewayTwo" ],
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": { "Ref": "PrivateRouteTableTwo" },
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": { "Ref": "NATGatewayTwo" }
}
},
"PrivateRouteTableOne": {
"Type": "AWS::EC2::RouteTable",
"Properties": { "VpcId": { "Ref": "VPC" } }
},
"PrivateRouteTableTwo": {
"Type": "AWS::EC2::RouteTable",
"Properties": { "VpcId": { "Ref": "VPC" } }
},
"InternetGateway": {
"Type": "AWS::EC2::InternetGateway"
},
"VPCGatewayAttachment": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": { "Ref": "VPC" },
"InternetGatewayId": { "Ref": "InternetGateway" }
}
},
"PublicRouteTable": {
"Type": "AWS::EC2::RouteTable",
"Properties": { "VpcId": { "Ref": "VPC" } }
},
"PublicRoute": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": { "Ref": "PublicRouteTable" },
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": { "Ref": "InternetGateway" }
}
},
"NATGatewayOne": {
"DependsOn": "InternetGateway",
"Type": "AWS::EC2::NatGateway",
"Properties": {
"AllocationId": { "Fn::GetAtt": [ "ElasticIPOne", "AllocationId" ] },
"SubnetId": { "Ref" : "PublicSubnetOne" }
}
},
"ElasticIPOne": {
"Type": "AWS::EC2::EIP",
"Properties": { "Domain": "vpc" }
},
"NATGatewayTwo": {
"DependsOn": "InternetGateway",
"Type": "AWS::EC2::NatGateway",
"Properties": {
"AllocationId": { "Fn::GetAtt": [ "ElasticIPTwo", "AllocationId"] },
"SubnetId": { "Ref" : "PublicSubnetTwo" }
}
},
"ElasticIPTwo": {
"Type": "AWS::EC2::EIP",
"Properties": { "Domain": "vpc" }
},
"DrupalElasticacheSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Elasticache Security Group",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "6379",
"ToPort": "6379",
"CidrIp": {"Ref": "PrivateSubnetOneCidr"}
},
{
"IpProtocol": "tcp",
"FromPort": "6379",
"ToPort": "6379",
"CidrIp": {"Ref": "PrivateSubnetTwoCidr"}
}
],
"VpcId": { "Ref": "VPC" }
}
},
"DrupalElasticacheSubnetGroup" : {
"Type" : "AWS::ElastiCache::SubnetGroup",
"Properties" : {
"Description" : "Cache Subnet Group",
"SubnetIds" : [
{ "Ref" : "PrivateSubnetOne" },
{ "Ref" : "PrivateSubnetTwo" }
]
}
},
"DrupalElasticacheCluster": {
"Type": "AWS::ElastiCache::CacheCluster",
"Properties": {
"CacheNodeType": "cache.t1.micro",
"AutoMinorVersionUpgrade": "true",
"Engine": "redis",
"NumCacheNodes": "1",
"VpcSecurityGroupIds": [
{ "Ref": "DrupalElasticacheSecurityGroup" }
],
"CacheSubnetGroupName": {
"Ref": "DrupalElasticacheSubnetGroup"
}
}
},
"Drupal7DBSubnetGroup" : {
"Type" : "AWS::RDS::DBSubnetGroup",
"Properties" : {
"DBSubnetGroupDescription" : "Subnets available for the Drupal 7 DB Instance",
"SubnetIds" : [
{ "Ref": "PrivateSubnetOne" },
{ "Ref": "PrivateSubnetTwo" }
]
}
},
"Drupal7DbSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Security group for the Drupal 7 DB ",
"SecurityGroupIngress": [
{
"IpProtocol": "TCP",
"FromPort": "3306",
"ToPort": "3306",
"CidrIp": { "Ref": "PrivateSubnetOneCidr" }
},
{
"IpProtocol": "TCP",
"FromPort": "3306",
"ToPort": "3306",
"CidrIp": { "Ref": "PrivateSubnetTwoCidr" }
}
],
"VpcId": { "Ref": "VPC" },
"Tags": [
{
"Key": "Name",
"Value": "Security Group for Drupal 7 RDS instances"
}
]
}
},
"DrupalDb" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"AllocatedStorage" : { "Ref" : "DBAllocatedStorage" },
"VPCSecurityGroups" : [ { "Ref" : "Drupal7DbSecurityGroup"} ],
"DBInstanceClass" : { "Ref": "DBClass" },
"Engine": "MySQL",
"StorageType": "gp2",
"MultiAZ" : { "Ref": "MultiAZDatabase" },
"DBSubnetGroupName" : { "Ref" : "Drupal7DBSubnetGroup" },
"PreferredBackupWindow": "02:00-03:30",
"BackupRetentionPeriod": "7",
"PreferredMaintenanceWindow": "sun:04:00-sun:06:00",
"DBName": { "Ref": "DbName" },
"MasterUsername" : { "Ref": "DbMasterUsername" },
"MasterUserPassword" : { "Ref": "DbMasterPassword" },
"Tags": [
{ "Key" : "Name", "Value" : "Drupal 7 Database" }
]
},
"DeletionPolicy" : "Snapshot"
},
"DrupalELBPublicAccess": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Security group for public HTTP access",
"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"
}
],
"VpcId": { "Ref": "VPC" }
}
},
"DrupalWebServerSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Security group for the Drupal Web Server instances",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": { "Ref": "VpcCidrBlock"}
},
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": { "Ref": "VpcCidrBlock" }
}
],
"VpcId": { "Ref": "VPC" },
"Tags": [
{
"Key": "Name",
"Value": "Drupal web server host security group"
},
{
"Key": "Service",
"Value": "Drupal"
}
]
}
},
"DrupalWebServerAutoScalingGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"DependsOn": [ "MountTargetPrivateSubnetOne", "MountTargetPrivateSubnetTwo", "InternetGateway" ],
"Properties" : {
"AvailabilityZones" : [
{ "Fn::GetAtt" : [ "PrivateSubnetOne", "AvailabilityZone" ] },
{ "Fn::GetAtt" : [ "PrivateSubnetTwo", "AvailabilityZone" ] }
],
"LaunchConfigurationName" : { "Ref" : "LaunchConfigurationForDrupalWebServer" },
"MinSize" : "0",
"MaxSize" : "10",
"DesiredCapacity" : { "Ref" : "WebServerCapacity" },
"LoadBalancerNames" : [ { "Ref" : "DrupalWebServerElasticLoadBalancer" } ],
"VPCZoneIdentifier": [
{ "Ref": "PrivateSubnetOne" },
{ "Ref": "PrivateSubnetTwo" }
],
"Tags": [
{
"Key": "Name",
"Value": "Drupal Web Server",
"PropagateAtLaunch": true
},
{
"Key": "Service",
"Value": "Drupal",
"PropagateAtLaunch": true
}
]
},
"CreationPolicy" : {
"ResourceSignal" : {
"Timeout" : "PT5M",
"Count" : { "Ref" : "WebServerCapacity" }
}
},
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"MinInstancesInService": "1",
"MaxBatchSize": "1",
"PauseTime" : "PT15M",
"WaitOnResourceSignals": "true"
}
}
},
"DrupalWebServerElasticLoadBalancer" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"Subnets": [
{ "Ref": "PublicSubnetOne" },
{ "Ref": "PublicSubnetTwo" }
],
"CrossZone" : "true",
"LBCookieStickinessPolicy" : [ {
"PolicyName" : "CookieBasedPolicy"
} ],
"Listeners" : [
{
"LoadBalancerPort" : "80",
"InstancePort" : "80",
"Protocol" : "HTTP",
"PolicyNames" : [ "CookieBasedPolicy" ]
},
{
"LoadBalancerPort": "443",
"InstancePort": "80",
"Protocol": "HTTPS",
"PolicyNames" : [ "CookieBasedPolicy" ],
"SSLCertificateId": {
"Ref": "SslCertificateId"
}
}
],
"HealthCheck" : {
"Target" : "HTTP:80/install.php",
"HealthyThreshold" : "2",
"UnhealthyThreshold" : "5",
"Interval" : "10",
"Timeout" : "5"
},
"SecurityGroups": [ { "Ref": "DrupalELBPublicAccess" } ]
}
},
"LaunchConfigurationForDrupalWebServer": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"Comment1" : "Configure the bootstrap helpers to install Docker and docker compose",
"Comment2" : "The website content is downloaded as a Docker container",
"AWS::CloudFormation::Init" : {
"configSets" : {
"drupal_install" : [ "mount", "install", "run" ],
"drupal_reload" : [ "install", "run" ]
},
"mount" : {
"commands" : {
"10_mkdir" : {
"command" : {"Fn::Join" : [ "", [ "mkdir -p /", { "Ref" : "MountPoint" } ]]}
},
"20_mount" : {
"command" : { "Fn::Join": [ "", [
"mount -t nfs4 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).",
{ "Ref": "SharedFileSystem" },
".efs.",
{ "Ref": "AWS::Region" },
".amazonaws.com:/ /",
{"Ref" : "MountPoint" }
] ] }
},
"30_mkdir_drupal" : {
"command" : {"Fn::Join" : [ "", [ "mkdir -p /", { "Ref" : "MountPoint" }, "/drupal-data" ]]}
},
"31_mkdir_drupal" : {
"command" : {"Fn::Join" : [ "", [ "mkdir -p /", { "Ref" : "MountPoint" }, "/drupal-private" ]]}
},
"40_permissions" : {
"command" : {"Fn::Join" : [ "", [
"chown ec2-user:ec2-user /", { "Ref" : "MountPoint" }, "\n",
"chown -R 33:33 /", { "Ref" : "MountPoint" }, "/drupal-data\n",
"chown -R 33:33 /", { "Ref" : "MountPoint" }, "/drupal-private\n"
]]}
}
}
},
"install" : {
"packages" : {
"yum" : {
"docker" : []
}
},
"services" : {
"sysvinit" : {
"docker" : {
"enabled" : "true",
"ensureRunning" : "true",
"packages" : { "yum" : ["docker"] }
}
}
},
"files" : {
"/tmp/install-docker-compose.sh": {
"content": { "Fn::Join" : [ "", [
"#!/bin/bash\n",
"curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose\n",
"chmod +x /usr/local/bin/docker-compose\n"
]]},
"mode" : "000755",
"owner" : "root",
"group" : "root"
}
},
"commands" : {
"10_install_docker_compose": {
"command" : "/tmp/install-docker-compose.sh",
"cwd" : "/tmp"
}
}
},
"run" : {
"files" : {
"/tmp/docker-compose.yml": {
"content": { "Fn::Join" : [ "", [
"version: '2'\n",
"services:\n",
" drupal:\n",
" image: ", { "Ref": "DockerImage" } ,"\n",
" restart: always\n",
" ports:\n",
" - \"80:80\"\n",
" environment:\n",
" DRUPAL_DB_NAME: ", { "Ref": "DbName" } ,"\n",
" DRUPAL_DB_USER: ", { "Ref": "DbMasterUsername" } ,"\n",
" DRUPAL_DB_PASS: ", { "Ref": "DbMasterPassword" } ,"\n",
" DRUPAL_DB_HOST: ", { "Fn::GetAtt" : [ "DrupalDb", "Endpoint.Address" ] } ,"\n",
" DRUPAL_REDIS_HOST: ", { "Fn::GetAtt" : [ "DrupalElasticacheCluster", "RedisEndpoint.Address" ] },"\n",
" DRUPAL_REDIS_POST: ", { "Fn::GetAtt" : [ "DrupalElasticacheCluster", "RedisEndpoint.Port" ] },"\n",
" logging:\n",
" driver: syslog\n",
" options:\n",
" syslog-address: \"", { "Ref": "SyslogDestination" } ,"\"\n",
" volumes:\n",
" - /", { "Ref" : "MountPoint" } , "/drupal-data:/var/www/html/sites/default/files\n",
" - /", { "Ref" : "MountPoint" } , "/drupal-private:/data/private\n"
]]},
"mode" : "000644",
"owner" : "root",
"group" : "root"
},
"/etc/cfn/cfn-hup.conf" : {
"content" : { "Fn::Join" : ["", [
"[main]\n",
"stack=", { "Ref" : "AWS::StackId" }, "\n",
"region=", { "Ref" : "AWS::Region" }, "\n"
]]},
"mode" : "000400",
"owner" : "root",
"group" : "root"
},
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : {
"content": { "Fn::Join" : ["", [
"[cfn-auto-reloader-hook]\n",
"triggers=post.update\n",
"path=Resources.LaunchConfigurationForDrupalWebServer.Metadata.AWS::CloudFormation::Init\n",
"action=/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource LaunchConfigurationForDrupalWebServer ",
" --configsets reload_drupal ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"runas=root\n"
]]}
}
},
"services" : {
"sysvinit" : {
"cfn-hup" : { "enabled" : "true", "ensureRunning" : "true",
"files" : ["/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf"]}
}
},
"commands" : {
"10_compose_up" : {
"command" : "/usr/local/bin/docker-compose up -d",
"cwd" : "/tmp"
}
}
}
}
},
"Properties": {
"ImageId": {
"Fn::FindInMap" : [ "AmazonMachineImages", { "Ref" : "AWS::Region" }, "64"]
},
"InstanceMonitoring": false,
"InstanceType": { "Ref": "WebServerInstanceType" },
"KeyName": { "Ref": "KeyPairName" },
"SecurityGroups": [
{ "Ref": "DrupalWebServerSecurityGroup" }
],
"BlockDeviceMappings" : [ {
"DeviceName" : "/dev/xvda",
"Ebs" : { "VolumeSize" : "30", "DeleteOnTermination" : "true"}
} ],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y aws-cfn-bootstrap\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource LaunchConfigurationForDrupalWebServer ",
" --configsets drupal_install ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource DrupalWebServerAutoScalingGroup ",
" --region ", { "Ref" : "AWS::Region" }, "\n"
]]}}
}
}
}
}