Commit 179c986f by Feanil Patel

Add support for a forums application and a mongo database.

parent 77d31c83
......@@ -58,6 +58,52 @@
],
"ConstraintDescription":"must be a valid EC2 instance type."
},
"ForumInstanceType":{
"Description":"Worker EC2 instance type",
"Type":"String",
"Default":"m1.small",
"AllowedValues":[
"t1.micro",
"m1.small",
"m1.medium",
"m1.large",
"m1.xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"m3.xlarge",
"m3.2xlarge",
"c1.medium",
"c1.xlarge",
"cc1.4xlarge",
"cc2.8xlarge",
"cg1.4xlarge"
],
"ConstraintDescription":"must be a valid EC2 instance type."
},
"MongoInstanceType":{
"Description":"Worker EC2 instance type",
"Type":"String",
"Default":"m1.small",
"AllowedValues":[
"t1.micro",
"m1.small",
"m1.medium",
"m1.large",
"m1.xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"m3.xlarge",
"m3.2xlarge",
"c1.medium",
"c1.xlarge",
"cc1.4xlarge",
"cc2.8xlarge",
"cg1.4xlarge"
],
"ConstraintDescription":"must be a valid EC2 instance type."
},
"RabbitInstanceType":{
"Description":"RabbitMQ server EC2 instance type",
"Type":"String",
......@@ -95,6 +141,11 @@
"Type":"Number",
"Default":"80"
},
"ForumServerPort":{
"Description":"The TCP port for the Web Server",
"Type":"Number",
"Default":"80"
},
"CacheNodePort":{
"Description":"The TCP port for the nodes in the Elasticache cluster",
"Type":"Number",
......@@ -176,6 +227,16 @@
"Type":"Number",
"Default":"2"
},
"ForumDesiredCapacity":{
"Description":"The Auto-scaling group desired capacity for the forums hosts",
"Type":"Number",
"Default":"2"
},
"MongoDesiredCapacity":{
"Description":"The Auto-scaling group desired capacity for the mongodb hosts",
"Type":"Number",
"Default":"2"
},
"CacheNodeType":{
"Default":"cache.m1.small",
"Description":"The compute and memory capacity of the nodes in the Cache Cluster",
......@@ -250,6 +311,14 @@
"MinValue":"5",
"MaxValue":"3072",
"ConstraintDescription":"must be between 5 and 3072Gb."
},
"MongoVolumeSize":{
"Default":"5",
"Description":"The size of the mongodb volumes(Gb). Because of RAID double the volume size will be available for mongo to use.",
"Type":"Number",
"MinValue":"5",
"MaxValue":"3072",
"ConstraintDescription":"must be between 5 and 3072Gb."
}
},
"Mappings":{
......@@ -265,13 +334,14 @@
"m3.xlarge": { "Arch":"64" },
"m3.2xlarge": { "Arch":"64" },
"c1.medium": { "Arch":"64" },
"c1.xlarge": { "Arch":"64" }
"c1.xlarge": { "Arch":"64" },
"cg1.4xlarge": { "Arch":"64HVM" }
},
"AWSRegionArch2AMI":{
"us-east-1": { "32":"ami-def89fb7", "64":"ami-d0f89fb9" },
"us-east-1": { "32":"ami-def89fb7", "64":"ami-d0f89fb9", "64HVM":"ami-b93264d0" },
"us-west-1": { "32":"ami-fc002cb9", "64":"ami-fe002cbb" },
"us-west-2": { "32":"ami-0ef96e3e", "64":"ami-70f96e40" },
"eu-west-1": { "32":"ami-c27b6fb6", "64":"ami-ce7b6fba" },
"us-west-2": { "32":"ami-0ef96e3e", "64":"ami-70f96e40", "64HVM":"ami-6cad335c" },
"eu-west-1": { "32":"ami-c27b6fb6", "64":"ami-ce7b6fba", "64HVM":"ami-8c987efb" },
"sa-east-1": { "32":"ami-a1da00bc", "64":"ami-a3da00be" },
"ap-southeast-1": { "32":"ami-66084734", "64":"ami-64084736" },
"ap-southeast-2": { "32":"ami-06ea7a3c", "64":"ami-04ea7a3e" },
......@@ -304,7 +374,11 @@
"Cache01": { "CIDR":"10.0.60.0/24" },
"Cache02": { "CIDR":"10.0.61.0/24" },
"Worker01": { "CIDR":"10.0.70.0/24" },
"Worker02": { "CIDR":"10.0.71.0/24" }
"Worker02": { "CIDR":"10.0.71.0/24" },
"Forum01": { "CIDR":"10.0.80.0/24" },
"Forum02": { "CIDR":"10.0.81.0/24" },
"Mongo01": { "CIDR":"10.0.90.0/24" },
"Mongo02": { "CIDR":"10.0.91.0/24" }
},
"MapRegionsToAvailZones":{
"us-east-1": { "AZone2":"us-east-1a", "AZone0":"us-east-1b", "AZone1":"us-east-1c" },
......@@ -817,6 +891,134 @@
]
}
},
"ForumSubnet01":{
"Type":"AWS::EC2::Subnet",
"Properties":{
"VpcId":{
"Ref":"EdxVPC"
},
"CidrBlock":{
"Fn::FindInMap":[
"SubnetConfig",
"Forum01",
"CIDR"
]
},
"AvailabilityZone":{
"Fn::FindInMap":[
"MapRegionsToAvailZones",
{ "Ref":"AWS::Region" },
"AZone0"
]
},
"Tags":[
{
"Key":"Application",
"Value":"forum"
},
{
"Key":"Network",
"Value":"Private"
}
]
}
},
"ForumSubnet02":{
"Type":"AWS::EC2::Subnet",
"Properties":{
"VpcId":{
"Ref":"EdxVPC"
},
"CidrBlock":{
"Fn::FindInMap":[
"SubnetConfig",
"Forum02",
"CIDR"
]
},
"AvailabilityZone":{
"Fn::FindInMap":[
"MapRegionsToAvailZones",
{ "Ref":"AWS::Region" },
"AZone1"
]
},
"Tags":[
{
"Key":"Application",
"Value":"forum"
},
{
"Key":"Network",
"Value":"Private"
}
]
}
},
"MongoSubnet01":{
"Type":"AWS::EC2::Subnet",
"Properties":{
"VpcId":{
"Ref":"EdxVPC"
},
"CidrBlock":{
"Fn::FindInMap":[
"SubnetConfig",
"Mongo01",
"CIDR"
]
},
"AvailabilityZone":{
"Fn::FindInMap":[
"MapRegionsToAvailZones",
{ "Ref":"AWS::Region" },
"AZone0"
]
},
"Tags":[
{
"Key":"Application",
"Value":"mongo"
},
{
"Key":"Network",
"Value":"Private"
}
]
}
},
"MongoSubnet02":{
"Type":"AWS::EC2::Subnet",
"Properties":{
"VpcId":{
"Ref":"EdxVPC"
},
"CidrBlock":{
"Fn::FindInMap":[
"SubnetConfig",
"Mongo02",
"CIDR"
]
},
"AvailabilityZone":{
"Fn::FindInMap":[
"MapRegionsToAvailZones",
{ "Ref":"AWS::Region" },
"AZone1"
]
},
"Tags":[
{
"Key":"Application",
"Value":"mongo"
},
{
"Key":"Network",
"Value":"Private"
}
]
}
},
"InternetGateway":{
"Type":"AWS::EC2::InternetGateway",
"Properties":{
......@@ -1282,6 +1484,50 @@
}
}
},
"PrivateSubnetRouteTableAssociationForum01":{
"Type":"AWS::EC2::SubnetRouteTableAssociation",
"Properties":{
"SubnetId":{
"Ref":"ForumSubnet01"
},
"RouteTableId":{
"Ref":"PrivateRouteTable"
}
}
},
"PrivateSubnetRouteTableAssociationForum02":{
"Type":"AWS::EC2::SubnetRouteTableAssociation",
"Properties":{
"SubnetId":{
"Ref":"ForumSubnet02"
},
"RouteTableId":{
"Ref":"PrivateRouteTable"
}
}
},
"PrivateSubnetRouteTableAssociationMongo01":{
"Type":"AWS::EC2::SubnetRouteTableAssociation",
"Properties":{
"SubnetId":{
"Ref":"MongoSubnet01"
},
"RouteTableId":{
"Ref":"PrivateRouteTable"
}
}
},
"PrivateSubnetRouteTableAssociationMongo02":{
"Type":"AWS::EC2::SubnetRouteTableAssociation",
"Properties":{
"SubnetId":{
"Ref":"MongoSubnet02"
},
"RouteTableId":{
"Ref":"PrivateRouteTable"
}
}
},
"PrivateNetworkAcl":{
"Type":"AWS::EC2::NetworkAcl",
"Properties":{
......@@ -1490,6 +1736,50 @@
}
}
},
"PrivateSubnetNetworkAclAssociationForum01":{
"Type":"AWS::EC2::SubnetNetworkAclAssociation",
"Properties":{
"SubnetId":{
"Ref":"WorkerSubnet01"
},
"NetworkAclId":{
"Ref":"PrivateNetworkAcl"
}
}
},
"PrivateSubnetNetworkAclAssociationForum02":{
"Type":"AWS::EC2::SubnetNetworkAclAssociation",
"Properties":{
"SubnetId":{
"Ref":"WorkerSubnet02"
},
"NetworkAclId":{
"Ref":"PrivateNetworkAcl"
}
}
},
"PrivateSubnetNetworkAclAssociationMongo01":{
"Type":"AWS::EC2::SubnetNetworkAclAssociation",
"Properties":{
"SubnetId":{
"Ref":"WorkerSubnet01"
},
"NetworkAclId":{
"Ref":"PrivateNetworkAcl"
}
}
},
"PrivateSubnetNetworkAclAssociationMongo02":{
"Type":"AWS::EC2::SubnetNetworkAclAssociation",
"Properties":{
"SubnetId":{
"Ref":"WorkerSubnet02"
},
"NetworkAclId":{
"Ref":"PrivateNetworkAcl"
}
}
},
"NATIPAddress":{
"Type":"AWS::EC2::EIP",
"Properties":{
......@@ -4104,15 +4394,781 @@
]
}
},
"EdxServerWaitHandle":{
"WorkerServerWaitHandle":{
"Type":"AWS::CloudFormation::WaitConditionHandle"
},
"EdxServerWaitCondition":{
"Type":"AWS::CloudFormation::WaitCondition",
"DependsOn":"WorkerServer",
"DependsOn":"EdxappServer",
"Properties":{
"Handle":{
"Ref":"EdxServerWaitHandle"
"Ref":"WorkerServerWaitHandle"
},
"Timeout":"1200"
}
},
"ForumServer":{
"Type":"AWS::AutoScaling::LaunchConfiguration",
"Metadata":{
"AWS::CloudFormation::Init":{
"config":{
"files":{
"/home/ubuntu/.s3cfg":{
"content":{
"Fn::Join":[
"",
[
"[default]\n",
"access_key = ",
{
"Ref":"HostKeys"
},
"\n",
"secret_key = ",
{
"Fn::GetAtt":[
"HostKeys",
"SecretAccessKey"
]
},
"\n",
"use_https = True\n"
]
]
},
"mode":"000644",
"owner":"ubuntu",
"group":"ubuntu"
}
}
}
}
},
"Properties":{
"SecurityGroups":[
{
"Ref":"ForumServerSecurityGroup"
}
],
"ImageId":{
"Fn::FindInMap":[
"AWSRegionArch2AMI",
{
"Ref":"AWS::Region"
},
{
"Fn::FindInMap":[
"AWSInstanceType2Arch",
{
"Ref":"ForumInstanceType"
},
"Arch"
]
}
]
},
"UserData":{
"Fn::Base64":{
"Fn::Join":[
"",
[
"#!/bin/bash\n",
"exec >> /home/ubuntu/cflog.log\n",
"exec 2>> /home/ubuntu/cflog.log\n",
"function error_exit\n",
"{\n",
" cfn-signal -e 1 -r \"$1\" '",
{
"Ref":"ForumServerWaitHandle"
},
"'\n",
" exit 1\n",
"}\n",
"for dev in /dev/xvdc /dev/xvdd; do sudo echo w | fdisk $dev; sudo mkfs -t ext4 $dev;done;\n",
"sudo mkdir /mnt/logs\n",
"sudo mount /dev/xvdc /mnt/logs\n",
"sudo mount /dev/xvdd /opt\n",
"apt-get -y update\n",
"apt-get -y install python-setuptools\n",
"echo \"Python Tools installed\" - `date` >> /home/ubuntu/cflog.txt\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"echo \"Cloudformation Boostrap installed \" - `date` >> /home/ubuntu/cflog.txt\n",
"cfn-init --region ",
{
"Ref":"AWS::Region"
},
" -s ",
{
"Ref":"AWS::StackName"
},
" -r ForumServer ",
" --access-key ",
{
"Ref":"HostKeys"
},
" --secret-key ",
{
"Fn::GetAtt":[
"HostKeys",
"SecretAccessKey"
]
},
" || error_exit 'Failed to run cfn-init'\n",
"echo \"cfn-init run \" - `date` >> /home/ubuntu/cflog.txt\n",
"# If all went well, signal success\n",
"cfn-signal -e $? -r 'Edx Server configuration' '",
{
"Ref":"ForumServerWaitHandle"
},
"'\n"
]
]
}
},
"KeyName":{
"Ref":"KeyName"
},
"InstanceType":{
"Ref":"InstanceType"
},
"BlockDeviceMappings":[
{
"DeviceName":"/dev/xvdc",
"Ebs":{
"VolumeSize":"50"
}
},
{
"DeviceName":"/dev/xvdd",
"Ebs":{
"VolumeSize":"50"
}
}
]
}
},
"ForumServerASGroup":{
"Type":"AWS::AutoScaling::AutoScalingGroup",
"Properties":{
"AvailabilityZones":[
{
"Fn::GetAtt":[
"ForumSubnet01",
"AvailabilityZone"
]
},
{
"Fn::GetAtt":[
"ForumSubnet02",
"AvailabilityZone"
]
}
],
"VPCZoneIdentifier":[
{
"Ref":"ForumSubnet01"
},
{
"Ref":"ForumSubnet02"
}
],
"Tags":[
{
"Key":"group",
"Value":"forum",
"PropagateAtLaunch":true
},
{
"Key":"environment",
"Value":{
"Ref":"EnvironmentTag"
},
"PropagateAtLaunch":true
}
],
"LaunchConfigurationName":{
"Ref":"ForumServer"
},
"MinSize":"2",
"MaxSize":"2",
"DesiredCapacity":{
"Ref":"ForumDesiredCapacity"
},
"LoadBalancerNames":[
{
"Ref":"ForumELB"
}
]
}
},
"ForumServerScaleUpPolicy":{
"Type":"AWS::AutoScaling::ScalingPolicy",
"Properties":{
"AdjustmentType":"ChangeInCapacity",
"AutoScalingGroupName":{
"Ref":"ForumServerASGroup"
},
"Cooldown":"60",
"ScalingAdjustment":"1"
}
},
"ForumServerScaleDownPolicy":{
"Type":"AWS::AutoScaling::ScalingPolicy",
"Properties":{
"AdjustmentType":"ChangeInCapacity",
"AutoScalingGroupName":{
"Ref":"ForumServerASGroup"
},
"Cooldown":"60",
"ScalingAdjustment":"-1"
}
},
"ForumCPUAlarmHigh":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"AlarmDescription":"Scale-up if CPU > 90% for 10 minutes",
"MetricName":"CPUUtilization",
"Namespace":"AWS/EC2",
"Statistic":"Average",
"Period":"300",
"EvaluationPeriods":"2",
"Threshold":"90",
"AlarmActions":[
{
"Ref":"ForumServerScaleUpPolicy"
}
],
"Dimensions":[
{
"Name":"AutoScalingGroupName",
"Value":{
"Ref":"ForumServerASGroup"
}
}
],
"ComparisonOperator":"GreaterThanThreshold"
}
},
"ForumCPUAlarmLow":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"AlarmDescription":"Scale-down if CPU < 70% for 10 minutes",
"MetricName":"CPUUtilization",
"Namespace":"AWS/EC2",
"Statistic":"Average",
"Period":"300",
"EvaluationPeriods":"2",
"Threshold":"70",
"AlarmActions":[
{
"Ref":"ForumServerScaleDownPolicy"
}
],
"Dimensions":[
{
"Name":"AutoScalingGroupName",
"Value":{
"Ref":"ForumServerASGroup"
}
}
],
"ComparisonOperator":"LessThanThreshold"
}
},
"ForumELB":{
"Type":"AWS::ElasticLoadBalancing::LoadBalancer",
"Properties":{
"SecurityGroups":[
{
"Ref":"ForumELBSecurityGroup"
}
],
"Listeners":[
{
"LoadBalancerPort":"80",
"InstancePort":{
"Ref":"ForumServerPort"
},
"Protocol":"HTTP"
},
{
"LoadBalancerPort":"443",
"InstancePort":{
"Ref":"ForumServerPort"
},
"Protocol":"HTTPS",
"InstanceProtocol":"HTTP",
"SSLCertificateId": {
"Ref": "SSLCertificateARN"
}
}
],
"HealthCheck":{
"Target":"HTTP:80",
"HealthyThreshold":"3",
"UnhealthyThreshold":"5",
"Interval":"30",
"Timeout":"5"
},
"Subnets":[
{
"Ref":"PublicSubnet01"
},
{
"Ref":"PublicSubnet02"
}
]
}
},
"ForumELBSecurityGroup":{
"Type":"AWS::EC2::SecurityGroup",
"Properties":{
"GroupDescription":"Enable HTTP access on port 80",
"VpcId":{
"Ref":"EdxVPC"
},
"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"
}
],
"SecurityGroupEgress":[
{
"IpProtocol":"tcp",
"FromPort":"80",
"ToPort":"80",
"CidrIp":"0.0.0.0/0"
},
{
"IpProtocol":"tcp",
"FromPort":"443",
"ToPort":"443",
"CidrIp":"0.0.0.0/0"
}
]
}
},
"ForumServerSecurityGroup":{
"Type":"AWS::EC2::SecurityGroup",
"Properties":{
"GroupDescription":"Open up SSH access plus Edx Server required ports",
"VpcId":{
"Ref":"EdxVPC"
},
"SecurityGroupIngress":[
{
"IpProtocol":"tcp",
"FromPort":"22",
"ToPort":"22",
"CidrIp":{
"Ref":"SSHLocation"
}
},
{
"IpProtocol":"tcp",
"FromPort":"80",
"ToPort":"80",
"CidrIp":"0.0.0.0/0"
},
{
"IpProtocol":"tcp",
"FromPort":"443",
"ToPort":"443",
"CidrIp":"0.0.0.0/0"
}
]
}
},
"ForumServerWaitHandle":{
"Type":"AWS::CloudFormation::WaitConditionHandle"
},
"ForumServerWaitCondition":{
"Type":"AWS::CloudFormation::WaitCondition",
"DependsOn":"ForumServer",
"Properties":{
"Handle":{
"Ref":"ForumServerWaitHandle"
},
"Timeout":"1200"
}
},
"MongoServer":{
"Type":"AWS::AutoScaling::LaunchConfiguration",
"Metadata":{
"AWS::CloudFormation::Init":{
"config":{
"files":{
"/home/ubuntu/.s3cfg":{
"content":{
"Fn::Join":[
"",
[
"[default]\n",
"access_key = ",
{
"Ref":"HostKeys"
},
"\n",
"secret_key = ",
{
"Fn::GetAtt":[
"HostKeys",
"SecretAccessKey"
]
},
"\n",
"use_https = True\n"
]
]
},
"mode":"000644",
"owner":"ubuntu",
"group":"ubuntu"
}
}
}
}
},
"Properties":{
"SecurityGroups":[
{
"Ref":"MongoServerSecurityGroup"
}
],
"ImageId":{
"Fn::FindInMap":[
"AWSRegionArch2AMI",
{
"Ref":"AWS::Region"
},
{
"Fn::FindInMap":[
"AWSInstanceType2Arch",
{
"Ref":"MongoInstanceType"
},
"Arch"
]
}
]
},
"UserData":{
"Fn::Base64":{
"Fn::Join":[
"",
[
"#!/bin/bash\n",
"exec >> /home/ubuntu/cflog.log\n",
"exec 2>> /home/ubuntu/cflog.log\n",
"function error_exit\n",
"{\n",
" cfn-signal -e 1 -r \"$1\" '",
{
"Ref":"MongoServerWaitHandle"
},
"'\n",
" exit 1\n",
"}\n",
"apt-get -y update\n",
"apt-get -y install python-setuptools\n",
"echo \"Python Tools installed\" - `date` >> /home/ubuntu/cflog.txt\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"echo \"Cloudformation Boostrap installed \" - `date` >> /home/ubuntu/cflog.txt\n",
"cfn-init --region ",
{
"Ref":"AWS::Region"
},
" -s ",
{
"Ref":"AWS::StackName"
},
" -r MongoServer ",
" --access-key ",
{
"Ref":"HostKeys"
},
" --secret-key ",
{
"Fn::GetAtt":[
"HostKeys",
"SecretAccessKey"
]
},
" || error_exit 'Failed to run cfn-init'\n",
"echo \"cfn-init run \" - `date` >> /home/ubuntu/cflog.txt\n",
"## Waiting for EBS mounts to become available\n",
"while [ ! -e /dev/sdh1 ]; do echo waiting for /dev/sdh1 to attach; sleep 10; done\n",
"while [ ! -e /dev/sdh2 ]; do echo waiting for /dev/sdh2 to attach; sleep 10; done\n",
"while [ ! -e /dev/sdh3 ]; do echo waiting for /dev/sdh3 to attach; sleep 10; done\n",
"while [ ! -e /dev/sdh4 ]; do echo waiting for /dev/sdh4 to attach; sleep 10; done\n",
"## Create RAID10 and persist configuration\n",
"mdadm --verbose --create /dev/md0 --level=10 --chunk=256 --raid-devices=4 /dev/sdh1 /dev/sdh2 /dev/sdh3 /dev/sdh4 > /tmp/mdadm.log 2>&1\n",
"echo '`mdadm --detail --scan`' | tee -a /etc/mdadm.conf\n",
"## Set read-ahead on each device\n",
"blockdev --setra 128 /dev/md0\n",
"blockdev --setra 128 /dev/sdh1\n",
"blockdev --setra 128 /dev/sdh2\n",
"blockdev --setra 128 /dev/sdh3\n",
"blockdev --setra 128 /dev/sdh4\n",
"## Create physical and logical volumes\n",
"dd if=/dev/zero of=/dev/md0 bs=512 count=1\n",
"pvcreate /dev/md0\n",
"vgcreate vg0 /dev/md0\n",
"lvcreate -l 90%vg -n data vg0\n",
"lvcreate -l 5%vg -n log vg0\n",
"lvcreate -l 5%vg -n journal vg0\n",
"## Create filesystems and mount point info\n",
"mke2fs -t ext4 -F /dev/vg0/data > /tmp/mke2fs1.log 2>&1\n",
"mke2fs -t ext4 -F /dev/vg0/log > /tmp/mke2fs2.log 2>&1\n",
"mke2fs -t ext4 -F /dev/vg0/journal > /tmp/mke2fs3.log 2>&1\n",
"mkdir -p /edx/var/mongo/\n",
"mkdir /edx/var/mongo/data\n",
"mkdir /edx/var/log/mongo\n",
"mkdir /edx/var/mongo/journal\n",
"echo '/dev/vg0/data /edx/var/mongo/data ext4 defaults,auto,noatime,noexec 0 0' | tee -a /etc/fstab\n",
"echo '/dev/vg0/log /edx/var/log/mongo ext4 defaults,auto,noatime,noexec 0 0' | tee -a /etc/fstab\n",
"echo '/dev/vg0/journal /edx/var/mongo/journal ext4 defaults,auto,noatime,noexec 0 0' | tee -a /etc/fstab\n",
"mount /edx/var/mongo/data > /tmp/mount1.log 2>&1\n",
"mount /edx/var/log/mongo > /tmp/mount2.log 2>&1\n",
"mount /edx/var/mongo/journal > /tmp/mount3.log 2>&1\n",
"ln -s /edx/var/mongo/journal /edx/var/mongo/data/journal\n",
"# If all went well, signal success\n",
"cfn-signal -e $? -r 'Edx Server configuration' '",
{
"Ref":"MongoServerWaitHandle"
},
"'\n"
]
]
}
},
"KeyName":{
"Ref":"KeyName"
},
"InstanceType":{
"Ref":"InstanceType"
},
"BlockDeviceMappings":[
{
"DeviceName":"/dev/sdh1",
"Ebs":{
"VolumeSize": { "Ref":"MongoVolumeSize" }
}
},
{
"DeviceName":"/dev/sdh2",
"Ebs":{
"VolumeSize": { "Ref":"MongoVolumeSize" }
}
},
{
"DeviceName":"/dev/sdh3",
"Ebs":{
"VolumeSize": { "Ref":"MongoVolumeSize" }
}
},
{
"DeviceName":"/dev/sdh4",
"Ebs":{
"VolumeSize": { "Ref":"MongoVolumeSize" }
}
}
]
}
},
"MongoServerASGroup":{
"Type":"AWS::AutoScaling::AutoScalingGroup",
"Properties":{
"AvailabilityZones":[
{
"Fn::GetAtt":[
"MongoSubnet01",
"AvailabilityZone"
]
},
{
"Fn::GetAtt":[
"MongoSubnet02",
"AvailabilityZone"
]
}
],
"VPCZoneIdentifier":[
{
"Ref":"MongoSubnet01"
},
{
"Ref":"MongoSubnet02"
}
],
"Tags":[
{
"Key":"group",
"Value":"mongo",
"PropagateAtLaunch":true
},
{
"Key":"environment",
"Value":{
"Ref":"EnvironmentTag"
},
"PropagateAtLaunch":true
}
],
"LaunchConfigurationName":{
"Ref":"MongoServer"
},
"MinSize":"2",
"MaxSize":"2",
"DesiredCapacity":{
"Ref":"MongoDesiredCapacity"
}
}
},
"MongoServerScaleUpPolicy":{
"Type":"AWS::AutoScaling::ScalingPolicy",
"Properties":{
"AdjustmentType":"ChangeInCapacity",
"AutoScalingGroupName":{
"Ref":"MongoServerASGroup"
},
"Cooldown":"60",
"ScalingAdjustment":"1"
}
},
"MongoServerScaleDownPolicy":{
"Type":"AWS::AutoScaling::ScalingPolicy",
"Properties":{
"AdjustmentType":"ChangeInCapacity",
"AutoScalingGroupName":{
"Ref":"MongoServerASGroup"
},
"Cooldown":"60",
"ScalingAdjustment":"-1"
}
},
"MongoCPUAlarmHigh":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"AlarmDescription":"Scale-up if CPU > 90% for 10 minutes",
"MetricName":"CPUUtilization",
"Namespace":"AWS/EC2",
"Statistic":"Average",
"Period":"300",
"EvaluationPeriods":"2",
"Threshold":"90",
"AlarmActions":[
{
"Ref":"MongoServerScaleUpPolicy"
}
],
"Dimensions":[
{
"Name":"AutoScalingGroupName",
"Value":{
"Ref":"MongoServerASGroup"
}
}
],
"ComparisonOperator":"GreaterThanThreshold"
}
},
"MongoCPUAlarmLow":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"AlarmDescription":"Scale-down if CPU < 70% for 10 minutes",
"MetricName":"CPUUtilization",
"Namespace":"AWS/EC2",
"Statistic":"Average",
"Period":"300",
"EvaluationPeriods":"2",
"Threshold":"70",
"AlarmActions":[
{
"Ref":"MongoServerScaleDownPolicy"
}
],
"Dimensions":[
{
"Name":"AutoScalingGroupName",
"Value":{
"Ref":"MongoServerASGroup"
}
}
],
"ComparisonOperator":"LessThanThreshold"
}
},
"MongoServerSecurityGroup":{
"Type":"AWS::EC2::SecurityGroup",
"Properties":{
"GroupDescription":"Open up SSH access plus Edx Server required ports",
"VpcId":{
"Ref":"EdxVPC"
},
"SecurityGroupIngress":[
{
"IpProtocol":"tcp",
"FromPort":"22",
"ToPort":"22",
"CidrIp":{
"Ref":"SSHLocation"
}
},
{
"IpProtocol":"tcp",
"FromPort":"27017",
"ToPort":"27017",
"SourceSecurityGroupId": { "Ref": "EdxappServerSecurityGroup" }
},
{
"IpProtocol":"tcp",
"FromPort":"28017",
"ToPort":"28017",
"SourceSecurityGroupId": { "Ref": "EdxappServerSecurityGroup" }
},
{
"IpProtocol":"tcp",
"FromPort":"27017",
"ToPort":"27017",
"SourceSecurityGroupId": { "Ref": "WorkerServerSecurityGroup" }
},
{
"IpProtocol":"tcp",
"FromPort":"28017",
"ToPort":"28017",
"SourceSecurityGroupId": { "Ref": "WorkerServerSecurityGroup" }
}
]
}
},
"MongoServerWaitHandle":{
"Type":"AWS::CloudFormation::WaitConditionHandle"
},
"MongoServerWaitCondition":{
"Type":"AWS::CloudFormation::WaitCondition",
"DependsOn":"MongoServer",
"Properties":{
"Handle":{
"Ref":"MongoServerWaitHandle"
},
"Timeout":"1200"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment