usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [4/7] git commit: Broken! Graphite server doesn’t come up and there is a stop to prevent the servers from being finished if the commands don’t run
Date Fri, 18 Jul 2014 13:15:37 GMT
Broken! Graphite server doesn’t come up and there is a stop to prevent the servers from being finished if the commands don’t run


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5ec28c33
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5ec28c33
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5ec28c33

Branch: refs/heads/cloud-formation-scripts
Commit: 5ec28c33eedf1874a38a3862e5223f5a53efe77d
Parents: de32502
Author: grey <greyes@apigee.com>
Authored: Mon Jul 14 08:23:02 2014 -0700
Committer: grey <greyes@apigee.com>
Committed: Mon Jul 14 08:23:02 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/ugcluster-cf.json | 1737 +++++++++++++++++++------------
 1 file changed, 1088 insertions(+), 649 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ec28c33/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index f5f9de7..bc8093e 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -1,665 +1,1104 @@
 {
-    "AWSTemplateFormatVersion": "2010-09-09",
-    "Description": "Usergrid AWS Cluster",
-    "Parameters": {
-        "DnsSubDomain": {
-            "Description": "DNS name for stack, must not already exist in Route53.",
-            "Type": "String",
-            "Default": "ugtest"
-        },
-        "DnsDomain": {
-            "Description": "DNS domain for stack, must already exist in Route53",
-            "Type": "String",
-            "Default": "usergrid.com"
-        },
-        "ReleaseBucket": {
-            "Description": "S3 Bucket where Usergrid assembly is to be found.",
-            "Type": "String",
-            "Default": "ug-cloudformation"
-        },
-        "RestMinServers": {
-            "Description": "Minimum number of REST servers.",
-            "Type": "Number",
-            "Default": "3",
-            "MinValue": "3"
-        },
-        "RestMaxServers": {
-            "Description": "Maximum number REST servers.",
-            "Type": "Number",
-            "Default": "3",
-            "MinValue": "3"
-        },
-        "RestInstanceType": {
-            "Description": "Instance type for REST servers",
-            "Type": "String",
-            "Default": "m1.large",
-            "AllowedValues": ["m1.small", "m1.medium", "m1.large", "m1.xlarge", "m3.xlarge", "m3.large"],
-            "ConstraintDescription": "must be valid instance type."
-        },
-        "KeyPair": {
-            "Description": "EC2 key pair to be use for SSH access",
-            "Type": "String",
-            "Default": "ug-cloudformation"
-        },
-        "CassClusterName": {
-            "Description": "Name to be used for Cassandra cluster.",
-            "Type": "String",
-            "Default": "usergrid"
-        },
-        "CassNumServers": {
-            "Description": "Number of Cass servers to start.",
-            "Type": "Number",
-            "Default": "3",
-            "MinValue": "3"
-        },
-        "CassInstanceType": {
-            "Description": "Instance type for Cass servers",
-            "Type": "String",
-            "Default": "m1.xlarge",
-            "AllowedValues": ["m1.small", "m1.medium", "m1.large", "m1.xlarge", "m3.xlarge", "m3.2xlarge","c3.4xlarge"],
-            "ConstraintDescription": "must be valid instance type."
-        },
-        "CassReplicationFactor": {
-            "Description": "Cassandra replication factor",
-            "Type": "Number",
-            "Default": "3",
-            "MinValue": "3"
-        },
-        "SuperUserEmail": {
-            "Description": "Email for superuser user",
-            "Type": "String",
-            "Default": "dmjohnson+super@apigee.com"
-        },
-        "TestAdminUserEmail": {
-            "Description": "Email for test admin user",
-            "Type": "String",
-            "Default": "dmjohnson+admin@apigee.com"
-        },
-        "NotificationEmail": {
-            "Description": "Email for notifications",
-            "Type": "String",
-            "Default": "dmjohnson+super@apigee.com"
-        }
-    },
-    "Mappings": {
-        "AWSInstanceType2Arch": {
-            "m1.small": {"Arch": "64"},
-            "m1.medium": {"Arch": "64"},
-            "m1.large": {"Arch": "64"},
-            "m1.xlarge": {"Arch": "64"},
-            "m3.large":{"Arch": "64"},
-            "c3.4xlarge":{"Arch":"64"}
-
-        },
-        "AWSRegionArch2AMI": {
-            "ap-southeast-2": {"64": "ami-5993f663"},
-            "us-east-1": {"64": "ami-7cbd4f14"},
-            "us-west-2": {"64": "ami-2598ea15"}
-        },
-        "TwoAZs": {
-            "ap-southeast-2": {"AZ1": "ap-southeast-2a", "AZ2": "ap-southeast-2b"},
-            "us-east-1": {"AZ1": "us-east-1b", "AZ2": "us-east-1c"},
-            "us-west-2": {"AZ1": "us-west-2a", "AZ2": "us-west-2b"}
-        }
-    },
-    "Resources": {
-                "RestUser": {
-            "Type": "AWS::IAM::User",
-            "Properties": {
-                "Path": "/",
-                "Policies": [{
-                        "PolicyName": "root",
-                        "PolicyDocument": {"Statement": [{
-                                    "Effect": "Allow",
-                                    "Action": "*",
-                                    "Resource": "*"
-                                }]}
-                    }]
-            }
-        },
-        "RestKey": {
-            "Type": "AWS::IAM::AccessKey",
-            "Properties": {
-                "UserName": {"Ref": "RestUser"}
-            }
-        },
-        "CassUser": {
-            "Type": "AWS::IAM::User",
-            "Properties": {
-                "Path": "/",
-                "Policies": [{
-                        "PolicyName": "root",
-                        "PolicyDocument": {"Statement": [{
-                                    "Effect": "Allow",
-                                    "Action": "*",
-                                    "Resource": "*"
-                                }]}
-                    }]
-            }
-        },
-        "CassKey": {
-            "Type": "AWS::IAM::AccessKey",
-            "Properties": {
-                "UserName": {"Ref": "CassUser"}
-            }
-        },
-        "CassAutoScalingLaunchConfiguration": {
-            "Type": "AWS::AutoScaling::LaunchConfiguration",
-            "Properties": {
-                "UserData": {
-                    "Fn::Base64": {"Fn::Join": ["", [
-
-                                "#!/bin/bash -ex\n",
-
-                                "# CASSANDRA NODE STARTUP \n",
-
-                                "exec >/var/log/usergrid-bootstrap.log 2>&1\n",
-                                "\n",
-                                "mkdir -p /usr/share/usergrid\n",
-                                "\n",
-
-                                "# create script that sets our environment variables\n",
-                                "cat >/etc/profile.d/usergrid-env.sh <<EOF\n",
-                                    "alias sudo='sudo -E'\n",
-                                    "\n",
-                                    "export TYPE=cass\n",
-                                    "export STACK_NAME=", {"Ref": "AWS::StackName"}, "\n",
-                                    "\n",
-                                    "export PUBLIC_HOSTNAME=`(curl -s http://169.254.169.254/latest/meta-data/public-hostname)`\n",
-                                    "export INTERNAL_HOSTNAME=`(curl http://169.254.169.254/latest/meta-data/local-ipv4)`\n",
-                                    "\n",
-                                    "export EC2_INSTANCE_ID=`ec2metadata --instance-id`\n",
-                                    "export EC2_REGION=", {"Ref": "AWS::Region"}, "\n",
-                                    "export EC2_URL=https://ec2.amazonaws.com/\n",
-                                    "\n",
-                                    "export CASS_SECURITY_GROUP_NAME=", {"Ref": "CassSecurityGroup"}, "\n",
-                                    "\n",
-                                    "#export JVM_EXTRA_OPTS=-javaagent:/usr/share/cassandra/lib/priam-cass-extensions-1.2.24.jar", "\n",
-                                    "\n",
-                                    "export CASSANDRA_CLUSTER_NAME=", {"Ref": "CassClusterName"}, "\n",
-                                    "export CASSANDRA_NUM_SERVERS=", {"Ref": "CassNumServers"}, "\n",
-                                    "export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
-                                    "export CASSANDRA_REPLICATION_FACTOR=", {"Ref": "CassReplicationFactor"}, "\n",
-                                    "\n",
-                                    "export RELEASE_BUCKET=", {"Ref": "ReleaseBucket"}, "\n",
-                                    "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# put AWS creds in environment\n",
-                                "cat >/etc/profile.d/aws-credentials.sh <<EOF\n",
-                                "export AWS_ACCESS_KEY=", {"Ref": "CassKey"}, "\n",
-                                "export AWS_SECRET_KEY=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# put AWS creds Priam's config file\n",
-                                "cat >/etc/awscredential.properties <<EOF\n",
-                                "AWSACCESSID=", {"Ref": "CassKey"}, "\n",
-                                "AWSKEY=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# setup s3cmd (will be installed by init script) \n",
-                                "cat >/etc/s3cfg <<EOF\n",
-                                "access_key=", {"Ref": "CassKey"}, "\n",
-                                "secret_key=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "chmod 644 /etc/s3cfg\n",
-                                "ln -s /etc/s3cfg ~ubuntu/.s3cfg\n",
-                                "ln -s /etc/s3cfg ~root/.s3cfg\n",
-                                "\n",
-
-                                "# download usergrid and init script bundle from S3\n",
-                                "wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | apt-key add -\n",
-                                "wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list\n",
-                                "apt-get update\n",
-                                "apt-get -y install s3cmd\n",
-                                "cd /usr/share/usergrid\n",
-                                "s3cmd --config=/etc/s3cfg get s3://", {"Ref": "ReleaseBucket"}, "/awscluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "tar xvf awscluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "rm -fr awscluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "chmod 755 ./init_instance/*.sh\n",
-                                "cd ./init_instance\n",
-
-                                "# init as a Cassandra node \n",
-                                "sh ./init_db_server.sh\n"
-
-                            ]]}
-                },
-                "KeyName": {"Ref": "KeyPair"},
-                "ImageId": {
-                    "Fn::FindInMap": [
-                        "AWSRegionArch2AMI",
-                        {
-                            "Ref": "AWS::Region"
-                        },
-                        {
-                            "Fn::FindInMap": [
-                                "AWSInstanceType2Arch",
-                                {
-                                    "Ref": "CassInstanceType"
-                                },
-                                "Arch"
-                            ]
-                        }
-                    ]
-                },
-                "InstanceType": {
-                    "Ref": "CassInstanceType"
-                },
-                "IamInstanceProfile": {
-                    "Ref": "RootInstanceProfile"
-                },
-                "SecurityGroups": [{"Ref": "CassSecurityGroup"}]
-            }
-        },
-        "CassAutoScalingGroup": {
-            "Type": "AWS::AutoScaling::AutoScalingGroup",
-            "Version": "2009-05-15",
-            "Properties": {
-                "AvailabilityZones": {
-                    "Fn::GetAZs": ""
-                },
-                "LaunchConfigurationName": {
-                    "Ref": "CassAutoScalingLaunchConfiguration"
-                },
-                "MinSize": {"Ref": "CassNumServers"},
-                "MaxSize": {"Ref": "CassNumServers"},
-                "NotificationConfiguration": {
-                    "TopicARN": {"Ref": "NotificationTopic"},
-                    "NotificationTypes": [
-                        "autoscaling:EC2_INSTANCE_LAUNCH",
-                        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
-                        "autoscaling:EC2_INSTANCE_TERMINATE",
-                        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
-                    ]
-                }
-            }
-        },
-        "RestAutoScalingLaunchConfiguration": {
-            "Type": "AWS::AutoScaling::LaunchConfiguration",
-            "Properties": {
-                "UserData": {
-                    "Fn::Base64": {"Fn::Join": ["", [
-
-                                "#!/bin/bash -ex\n",
-
-                                "# REST SERVER STARTUP \n",
-
-                                "exec >/var/log/usergrid-bootstrap.log 2>&1\n",
-
-                                "\n",
-                                "mkdir -p /usr/share/usergrid\n",
-                                "\n",
-
-                                "# create script that sets our environment variables\n",
-                                "cat >/etc/profile.d/usergrid-env.sh <<EOF\n",
-                                    "alias sudo='sudo -E'\n",
-                                    "\n",
-                                    "export TYPE=rest\n",
-                                    "export STACK_NAME=", {"Ref": "AWS::StackName"}, "\n",
-                                    "\n",
-                                    "export DNS_NAME=", {"Ref": "DnsSubDomain"}, "\n",
-                                    "export DNS_DOMAIN=", {"Ref": "DnsDomain"}, "\n",
-                                    "export PUBLIC_HOSTNAME=`(curl -s http://169.254.169.254/latest/meta-data/public-hostname)`\n",
-                                    "export INTERNAL_HOSTNAME=`(curl http://169.254.169.254/latest/meta-data/local-ipv4)`\n",
-                                    "export ELB_NAME=", {"Ref": "RestElasticLoadBalancer"}, "\n",
-                                    "\n",
-                                    "export EC2_INSTANCE_ID=`ec2metadata --instance-id`\n",
-                                    "export EC2_REGION=", {"Ref": "AWS::Region"}, "\n",
-                                    "export EC2_URL=https://ec2.amazonaws.com/\n",
-                                    "\n",
-                                    "export REST_SECURITY_GROUP_NAME=", {"Ref": "RestSecurityGroup"}, "\n",
-                                    "export DB_SECURITY_GROUP_NAME=", {"Ref": "CassSecurityGroup"}, "\n",
-                                    "\n",
-                                    "export CASSANDRA_CLUSTER_NAME=", {"Ref": "CassClusterName"}, "\n",
-                                    "export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
-                                    "export CASSANDRA_NUM_SERVERS=", {"Ref": "CassNumServers"}, "\n",
-                                    "export CASSANDRA_REPLICATION_FACTOR=", {"Ref": "CassReplicationFactor"}, "\n",
-                                    "\n",
-                                    "export RELEASE_BUCKET=", {"Ref": "ReleaseBucket"}, "\n",
-                                    "\n",
-                                    "export SUPER_USER_EMAIL=", {"Ref": "SuperUserEmail"}, "\n",
-                                    "export TEST_ADMIN_USER_EMAIL=", {"Ref": "TestAdminUserEmail"}, "\n",
-                                    "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# put AWS creds in environment\n",
-                                "cat >/etc/profile.d/aws-credentials.sh <<EOF\n",
-                                "export AWS_ACCESS_KEY=", {"Ref": "RestKey"}, "\n",
-                                "export AWS_SECRET_KEY=", {"Fn::GetAtt": ["RestKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# setup s3cmd (will be installed by init script) \n",
-                                "cat >/etc/s3cfg <<EOF\n",
-                                "access_key=", {"Ref": "RestKey"}, "\n",
-                                "secret_key=", {"Fn::GetAtt": ["RestKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "chmod 644 /etc/s3cfg\n",
-                                "ln -s /etc/s3cfg ~ubuntu/.s3cfg\n",
-                                "ln -s /etc/s3cfg ~root/.s3cfg\n",
-                                "\n",
-
-                                "# download usergrid and init script bundle from S3\n",
-                                "wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | apt-key add -\n",
-                                "wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list\n",
-                                "apt-get update\n",
-                                "apt-get -y install s3cmd\n",
-                                "cd /usr/share/usergrid\n",
-                                "s3cmd --config=/etc/s3cfg get s3://", {"Ref": "ReleaseBucket"}, "/awscluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "tar xvf awscluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "rm -fr awscluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "chmod 755 ./init_instance/*.sh\n",
-                                "cd ./init_instance\n",
-
-                                "# Init as a REST intance \n",
-                                "sh ./init_rest_server.sh\n"
-
-                            ]]}
-                },
-                "KeyName": {"Ref": "KeyPair"},
-                "ImageId": {
-                    "Fn::FindInMap": [
-                        "AWSRegionArch2AMI",
-                        {
-                            "Ref": "AWS::Region"
-                        },
-                        {
-                            "Fn::FindInMap": [
-                                "AWSInstanceType2Arch",
-                                {
-                                    "Ref": "RestInstanceType"
-                                },
-                                "Arch"
-                            ]
-                        }
-                    ]
-                },
-                "InstanceType": {
-                    "Ref": "RestInstanceType"
-                },
-                "IamInstanceProfile": {
-                    "Ref": "RootInstanceProfile"
-                },
-                "SecurityGroups": [{"Ref": "RestSecurityGroup"}]
-            }
-        },
-        "RestAutoScalingGroup": {
-            "Type": "AWS::AutoScaling::AutoScalingGroup",
-            "Version": "2009-05-15",
-            "Properties": {
-                "AvailabilityZones": [
-                    {"Fn::FindInMap": ["TwoAZs", {"Ref": "AWS::Region"}, "AZ1"]},
-                    {"Fn::FindInMap": ["TwoAZs", {"Ref": "AWS::Region"}, "AZ2"]}
-                ],
-                "LaunchConfigurationName": {
-                    "Ref": "RestAutoScalingLaunchConfiguration"
-                },
-                "MinSize": {"Ref": "RestMinServers"},
-                "MaxSize": {"Ref": "RestMaxServers"},
-                "HealthCheckType": "ELB",
-                "HealthCheckGracePeriod": "1800",
-                "LoadBalancerNames": [{"Ref": "RestElasticLoadBalancer"}],
-                "NotificationConfiguration": {
-                    "TopicARN": {"Ref": "NotificationTopic"},
-                    "NotificationTypes": [
-                        "autoscaling:EC2_INSTANCE_LAUNCH",
-                        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
-                        "autoscaling:EC2_INSTANCE_TERMINATE",
-                        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
-                    ]
-                }
-            }
-        },
-        "RestServerScaleUpPolicy": {
-            "Type": "AWS::AutoScaling::ScalingPolicy",
-            "Properties": {
-                "AdjustmentType": "ChangeInCapacity",
-                "AutoScalingGroupName": {
-                    "Ref": "RestAutoScalingGroup"
-                },
-                "Cooldown": "60",
-                "ScalingAdjustment": "1"
-            }
-        },
-        "RestServerScaleDownPolicy": {
-            "Type": "AWS::AutoScaling::ScalingPolicy",
-            "Properties": {
-                "AdjustmentType": "ChangeInCapacity",
-                "AutoScalingGroupName": {
-                    "Ref": "RestAutoScalingGroup"
-                },
-                "Cooldown": "60",
-                "ScalingAdjustment": "-1"
-            }
-        },
-        "CPUAlarmHigh": {
-            "Type": "AWS::CloudWatch::Alarm",
-            "Properties": {
-                "AlarmDescription": "Scale-up if CPU > 60% for 10 minutes",
-                "MetricName": "CPUUtilization",
-                "Namespace": "AWS/EC2",
-                "Statistic": "Average",
-                "Period": "600",
-                "EvaluationPeriods": "2",
-                "Threshold": "60",
-                "AlarmActions": [{
-                        "Ref": "RestServerScaleUpPolicy"
-                    }],
-                "Dimensions": [
-                    {
-                        "Name": "AutoScalingGroupName",
-                        "Value": {
-                            "Ref": "RestAutoScalingGroup"
-                        }
-                    }],
-                "ComparisonOperator": "GreaterThanThreshold"
-            }
-        },
-        "CPUAlarmLow": {
-            "Type": "AWS::CloudWatch::Alarm",
-            "Properties": {
-                "AlarmDescription": "Scale-down if CPU < 10% for 10 minutes",
-                "MetricName": "CPUUtilization",
-                "Namespace": "AWS/EC2",
-                "Statistic": "Average",
-                "Period": "600",
-                "EvaluationPeriods": "2",
-                "Threshold": "10",
-                "AlarmActions": [{
-                        "Ref": "RestServerScaleDownPolicy"
-                    }],
-                "Dimensions": [
-                    {
-                        "Name": "AutoScalingGroupName",
-                        "Value": {
-                            "Ref": "RestAutoScalingGroup"
+   "AWSTemplateFormatVersion":"2010-09-09",
+   "Description":"Usergrid AWS Cluster",
+   "Parameters":{
+      "DnsSubDomain":{
+         "Description":"DNS name for stack, must not already exist in Route53.",
+         "Type":"String",
+         "Default":"ugtest"
+      },
+      "DnsDomain":{
+         "Description":"DNS domain for stack, must already exist in Route53",
+         "Type":"String",
+         "Default":"usergrid.com"
+      },
+      "ReleaseBucket":{
+         "Description":"S3 Bucket where Usergrid assembly is to be found.",
+         "Type":"String",
+         "Default":"ug-cloudformation"
+      },
+      "RestMinServers":{
+         "Description":"Minimum number of REST servers.",
+         "Type":"Number",
+         "Default":"3",
+         "MinValue":"3"
+      },
+      "RestMaxServers":{
+         "Description":"Maximum number REST servers.",
+         "Type":"Number",
+         "Default":"3",
+         "MinValue":"3"
+      },
+      "RestInstanceType":{
+         "Description":"Instance type for REST servers",
+         "Type":"String",
+         "Default":"m1.large",
+         "AllowedValues":[
+            "m1.small",
+            "m1.medium",
+            "m1.large",
+            "m1.xlarge",
+            "m3.xlarge",
+            "m3.large",
+            "c3.4xlarge"
+         ],
+         "ConstraintDescription":"must be valid instance type."
+      },
+      "KeyPair":{
+         "Description":"EC2 key pair to be use for SSH access",
+         "Type":"String",
+         "Default":"ug-cloudformation"
+      },
+      "CassClusterName":{
+         "Description":"Name to be used for Cassandra cluster.",
+         "Type":"String",
+         "Default":"usergrid"
+      },
+      "CassNumServers":{
+         "Description":"Number of Cass servers to start.",
+         "Type":"Number",
+         "Default":"3",
+         "MinValue":"3"
+      },
+      "CassInstanceType":{
+         "Description":"Instance type for Cass servers",
+         "Type":"String",
+         "Default":"m1.xlarge",
+         "AllowedValues":[
+            "m1.small",
+            "m1.medium",
+            "m1.large",
+            "m1.xlarge",
+            "m3.xlarge",
+            "m3.2xlarge",
+            "c3.4xlarge"
+         ],
+         "ConstraintDescription":"must be valid instance type."
+      },
+      "CassReplicationFactor":{
+         "Description":"Cassandra replication factor",
+         "Type":"Number",
+         "Default":"3",
+         "MinValue":"3"
+      },
+      "SuperUserEmail":{
+         "Description":"Email for superuser user",
+         "Type":"String",
+         "Default":"dmjohnson+super@apigee.com"
+      },
+      "TestAdminUserEmail":{
+         "Description":"Email for test admin user",
+         "Type":"String",
+         "Default":"dmjohnson+admin@apigee.com"
+      },
+      "NotificationEmail":{
+         "Description":"Email for notifications",
+         "Type":"String",
+         "Default":"dmjohnson+super@apigee.com"
+      },
+      "GraphiteInstanceType":{
+         "Description":"Instance type for Graphite server",
+         "Type":"String",
+         "Default":"m3.large",
+         "AllowedValues":[
+            "t1.micro",
+            "m1.small",
+            "m1.medium",
+            "m1.large",
+            "m3.large",
+            "m1.xlarge",
+            "m3.xlarge",
+            "m3.2xlarge",
+            "c3.4xlarge"
+         ],
+         "ConstraintDescription":"must be valid instance type."
+      },
+      "GraphiteServers":{
+         "Description":"Minimum number of graphite servers. There should only be one",
+         "Type":"Number",
+         "Default":"1",
+         "MinValue":"1"
+      }
+   },
+   "Mappings":{
+      "AWSInstanceType2Arch":{
+         "t1.micro":{
+            "Arch":"64"
+         },
+         "m1.small":{
+            "Arch":"64"
+         },
+         "m1.medium":{
+            "Arch":"64"
+         },
+         "m1.large":{
+            "Arch":"64"
+         },
+         "m1.xlarge":{
+            "Arch":"64"
+         },
+         "m3.large":{
+            "Arch":"64"
+         },
+         "m3.xlarge":{
+            "Arch":"64"
+         },
+         "c3.4xlarge":{
+            "Arch":"64"
+         }
+      },
+      "AWSRegionArch2AMI":{
+         "ap-southeast-2":{
+            "64":"ami-5993f663"
+         },
+         "us-east-1":{
+            "64":"ami-7cbd4f14"
+         },
+         "us-west-2":{
+            "64":"ami-2598ea15"
+         }
+      },
+      "TwoAZs":{
+         "ap-southeast-2":{
+            "AZ1":"ap-southeast-2a",
+            "AZ2":"ap-southeast-2b"
+         },
+         "us-east-1":{
+            "AZ1":"us-east-1b",
+            "AZ2":"us-east-1c"
+         },
+         "us-west-2":{
+            "AZ1":"us-west-2a",
+            "AZ2":"us-west-2b"
+         }
+      }
+   },
+   "Resources":{
+      "GraphiteUser":{
+         "Type":"AWS::IAM::User",
+         "Properties":{
+            "Path":"/",
+            "Policies":[
+               {
+                  "PolicyName":"root",
+                  "PolicyDocument":{
+                     "Statement":[
+                        {
+                           "Effect":"Allow",
+                           "Action":"*",
+                           "Resource":"*"
                         }
-                    }],
-                "ComparisonOperator": "LessThanThreshold"
+                     ]
+                  }
+               }
+            ]
+         }
+      },
+      "GraphiteKey":{
+         "Type":"AWS::IAM::AccessKey",
+         "Properties":{
+            "UserName":{
+               "Ref":"GraphiteUser"
             }
-        },
-        "RestElasticLoadBalancer": {
-            "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
-            "Properties": {
-                "AvailabilityZones": [
-                    {"Fn::FindInMap": ["TwoAZs", {"Ref": "AWS::Region"}, "AZ1"]},
-                    {"Fn::FindInMap": ["TwoAZs", {"Ref": "AWS::Region"}, "AZ2"]}
-                ],
-                "Listeners": [{
-                        "LoadBalancerPort": "80",
-                        "InstancePort": "8080",
-                        "Protocol": "HTTP"
-                    }],
-                "HealthCheck": {
-                    "Target": "HTTP:8080/status",
-                    "HealthyThreshold": "2",
-                    "UnhealthyThreshold": "4",
-                    "Interval": "30",
-                    "Timeout": "5"
-                }
-            }
-        },
-        "NotificationTopic": {
-            "Type": "AWS::SNS::Topic",
-            "Properties": {
-                "Subscription": [{
-                        "Endpoint": {"Ref": "NotificationEmail"},
-                        "Protocol": "email"
-                    }]
-            }
-        },
-        "DnsRecord": {
-            "Type": "AWS::Route53::RecordSetGroup",
-            "Properties": {
-                "HostedZoneName": {"Fn::Join": [".", [{"Ref": "DnsDomain"}, ""]]},
-                "RecordSets": [{
-                        "Name": {"Fn::Join": [".", [{"Ref": "DnsSubDomain"}, {"Ref": "DnsDomain"}]]},
-                        "Type": "A",
-                        "AliasTarget": {
-                            "HostedZoneId": {"Fn::GetAtt": ["RestElasticLoadBalancer", "CanonicalHostedZoneNameID"]},
-                            "DNSName": {"Fn::GetAtt": ["RestElasticLoadBalancer", "CanonicalHostedZoneName"]}
+         }
+      },
+      "GraphiteInstance":{
+         "Type":"AWS::EC2::Instance",
+         "Properties":{
+            "UserData":{
+               "Fn::Base64":{
+                  "Fn::Join":[
+                     "",
+                     [
+                        "#!/bin/bash -ex\n",
+                        "sudo git clone https://github.com/hopsoft/docker-graphite-statsd.git \n",
+                        "sudo ./docker-graphite-statsd/bin/start \n",
+                        "sudo git clone https://github.com/dotcloud/collectd-graphite.git \n",
+                        "sudo collectd-graphite/docker build -t collectd-graphite . \n"
+                     ]
+                  ]
+               }
+            },
+            "KeyName":{
+               "Ref":"KeyPair"
+            },
+            "ImageId":{
+               "Fn::FindInMap":[
+                  "AWSRegionArch2AMI",
+                  {
+                     "Ref":"AWS::Region"
+                  },
+                  {
+                     "Fn::FindInMap":[
+                        "AWSInstanceType2Arch",
+                        {
+                           "Ref":"GraphiteInstanceType"
+                        },
+                        "Arch"
+                     ]
+                  }
+               ]
+            },
+            "InstanceType":{
+               "Ref":"GraphiteInstanceType"
+            },
+            "IamInstanceProfile":{
+               "Ref":"RootInstanceProfile"
+            },
+            "SecurityGroups":[
+               "graphite"
+            ]
+         }
+      },
+      "WaitForInstanceWaitHandle":{
+         "Type":"AWS::CloudFormation::WaitConditionHandle"
+      },
+      "WaitForInstance":{
+         "Type":"AWS::CloudFormation::WaitCondition",
+         "DependsOn":"GraphiteInstance",
+         "Properties":{
+            "Handle":{
+               "Ref":"WaitForInstanceWaitHandle"
+            },
+            "Timeout":"4500"
+         }
+      },
+      "RestUser":{
+         "Type":"AWS::IAM::User",
+         "Properties":{
+            "Path":"/",
+            "Policies":[
+               {
+                  "PolicyName":"root",
+                  "PolicyDocument":{
+                     "Statement":[
+                        {
+                           "Effect":"Allow",
+                           "Action":"*",
+                           "Resource":"*"
                         }
-                    }]
+                     ]
+                  }
+               }
+            ]
+         }
+      },
+      "RestKey":{
+         "Type":"AWS::IAM::AccessKey",
+         "Properties":{
+            "UserName":{
+               "Ref":"RestUser"
             }
-        },
-
-        "RootRole": {
-            "Type": "AWS::IAM::Role",
-            "Properties": {
-                "AssumeRolePolicyDocument": {
-                    "Statement": [
-                        {
-                            "Effect": "Allow",
-                            "Principal": {
-                                "Service": [
-                                    "ec2.amazonaws.com"
-                                ]
-                            },
-                            "Action": [
-                                "sts:AssumeRole"
-                            ]
+         }
+      },
+      "CassUser":{
+         "Type":"AWS::IAM::User",
+         "Properties":{
+            "Path":"/",
+            "Policies":[
+               {
+                  "PolicyName":"root",
+                  "PolicyDocument":{
+                     "Statement":[
+                        {
+                           "Effect":"Allow",
+                           "Action":"*",
+                           "Resource":"*"
                         }
-                    ]
-                },
-                "Path": "/"
+                     ]
+                  }
+               }
+            ]
+         }
+      },
+      "CassKey":{
+         "Type":"AWS::IAM::AccessKey",
+         "Properties":{
+            "UserName":{
+               "Ref":"CassUser"
             }
-        },
-        "RolePolicies": {
-            "Type": "AWS::IAM::Policy",
-            "Properties": {
-                "PolicyName": "root",
-                "PolicyDocument": {
-                    "Statement": [
-                        {
-                            "Effect": "Allow",
-                            "Action": "*",
-                            "Resource": "*"
-                        }
-                    ]
-                },
-                "Roles": [
-                    {
-                        "Ref": "RootRole"
-                    }
-                ]
+         }
+      },
+      "CassAutoScalingLaunchConfiguration":{
+         "Type":"AWS::AutoScaling::LaunchConfiguration",
+         "Properties":{
+            "UserData":{
+               "Fn::Base64":{
+                  "Fn::Join":[
+                     "",
+                     [
+                        "#!/bin/bash -ex\n",
+                        "# CASSANDRA NODE STARTUP \n",
+                        "exec >/var/log/usergrid-bootstrap.log 2>&1\n",
+                        "\n",
+                        "mkdir -p /usr/share/usergrid\n",
+                        "\n",
+                        "# create script that sets our environment variables\n",
+                        "cat >/etc/profile.d/usergrid-env.sh <<EOF\n",
+                        "alias sudo='sudo -E'\n",
+                        "\n",
+                        "export TYPE=cass\n",
+                        "export STACK_NAME=",
+                        {
+                           "Ref":"AWS::StackName"
+                        },
+                        "\n",
+                        "\n",
+                        "export PUBLIC_HOSTNAME=`(curl -s http://169.254.169.254/latest/meta-data/public-hostname)`\n",
+                        "export INTERNAL_HOSTNAME=`(curl http://169.254.169.254/latest/meta-data/local-ipv4)`\n",
+                        "\n",
+                        "export EC2_INSTANCE_ID=`ec2metadata --instance-id`\n",
+                        "export EC2_REGION=",
+                        {
+                           "Ref":"AWS::Region"
+                        },
+                        "\n",
+                        "export EC2_URL=https://ec2.amazonaws.com/\n",
+                        "\n",
+                        "export CASS_SECURITY_GROUP_NAME=",
+                        {
+                           "Ref":"CassSecurityGroup"
+                        },
+                        "\n",
+                        "\n",
+                        "#export JVM_EXTRA_OPTS=-javaagent:/usr/share/cassandra/lib/priam-cass-extensions-1.2.24.jar",
+                        "\n",
+                        "\n",
+                        "export CASSANDRA_CLUSTER_NAME=",
+                        {
+                           "Ref":"CassClusterName"
+                        },
+                        "\n",
+                        "export CASSANDRA_NUM_SERVERS=",
+                        {
+                           "Ref":"CassNumServers"
+                        },
+                        "\n",
+                        "export CASSANDRA_KEYSPACE_NAME=usergrid",
+                        "\n",
+                        "export CASSANDRA_REPLICATION_FACTOR=",
+                        {
+                           "Ref":"CassReplicationFactor"
+                        },
+                        "\n",
+                        "\n",
+                        "export RELEASE_BUCKET=",
+                        {
+                           "Ref":"ReleaseBucket"
+                        },
+                        "\n",
+                        "\n",
+                        "EOF\n",
+                        "\n",
+                        "# put AWS creds in environment\n",
+                        "cat >/etc/profile.d/aws-credentials.sh <<EOF\n",
+                        "export AWS_ACCESS_KEY=",
+                        {
+                           "Ref":"CassKey"
+                        },
+                        "\n",
+                        "export AWS_SECRET_KEY=",
+                        {
+                           "Fn::GetAtt":[
+                              "CassKey",
+                              "SecretAccessKey"
+                           ]
+                        },
+                        "\n",
+                        "EOF\n",
+                        "\n",
+                        "# put AWS creds Priam's config file\n",
+                        "cat >/etc/awscredential.properties <<EOF\n",
+                        "AWSACCESSID=",
+                        {
+                           "Ref":"CassKey"
+                        },
+                        "\n",
+                        "AWSKEY=",
+                        {
+                           "Fn::GetAtt":[
+                              "CassKey",
+                              "SecretAccessKey"
+                           ]
+                        },
+                        "\n",
+                        "EOF\n",
+                        "\n",
+                        "# setup s3cmd (will be installed by init script) \n",
+                        "cat >/etc/s3cfg <<EOF\n",
+                        "access_key=",
+                        {
+                           "Ref":"CassKey"
+                        },
+                        "\n",
+                        "secret_key=",
+                        {
+                           "Fn::GetAtt":[
+                              "CassKey",
+                              "SecretAccessKey"
+                           ]
+                        },
+                        "\n",
+                        "EOF\n",
+                        "chmod 644 /etc/s3cfg\n",
+                        "ln -s /etc/s3cfg ~ubuntu/.s3cfg\n",
+                        "ln -s /etc/s3cfg ~root/.s3cfg\n",
+                        "\n",
+                        "# download usergrid and init script bundle from S3\n",
+                        "wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | apt-key add -\n",
+                        "wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list\n",
+                        "apt-get update\n",
+                        "apt-get -y install s3cmd\n",
+                        "cd /usr/share/usergrid\n",
+                        "s3cmd --config=/etc/s3cfg get s3://",
+                        {
+                           "Ref":"ReleaseBucket"
+                        },
+                        "/awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "tar xvf awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "rm -fr awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "chmod 755 ./init_instance/*.sh\n",
+                        "cd ./init_instance\n",
+                        "# init as a Cassandra node \n",
+                        "sh ./init_db_server.sh\n"
+                     ]
+                  ]
+               }
+            },
+            "KeyName":{
+               "Ref":"KeyPair"
+            },
+            "ImageId":{
+               "Fn::FindInMap":[
+                  "AWSRegionArch2AMI",
+                  {
+                     "Ref":"AWS::Region"
+                  },
+                  {
+                     "Fn::FindInMap":[
+                        "AWSInstanceType2Arch",
+                        {
+                           "Ref":"CassInstanceType"
+                        },
+                        "Arch"
+                     ]
+                  }
+               ]
+            },
+            "InstanceType":{
+               "Ref":"CassInstanceType"
+            },
+            "IamInstanceProfile":{
+               "Ref":"RootInstanceProfile"
+            },
+            "SecurityGroups":[
+               {
+                  "Ref":"CassSecurityGroup"
+               }
+            ]
+         }
+      },
+      "CassAutoScalingGroup":{
+         "Type":"AWS::AutoScaling::AutoScalingGroup",
+         "Version":"2009-05-15",
+         "Properties":{
+            "AvailabilityZones":{
+               "Fn::GetAZs":""
+            },
+            "LaunchConfigurationName":{
+               "Ref":"CassAutoScalingLaunchConfiguration"
+            },
+            "MinSize":{
+               "Ref":"CassNumServers"
+            },
+            "MaxSize":{
+               "Ref":"CassNumServers"
+            },
+            "NotificationConfiguration":{
+               "TopicARN":{
+                  "Ref":"NotificationTopic"
+               },
+               "NotificationTypes":[
+                  "autoscaling:EC2_INSTANCE_LAUNCH",
+                  "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
+                  "autoscaling:EC2_INSTANCE_TERMINATE",
+                  "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
+               ]
             }
-        },
-        "RootInstanceProfile": {
-            "Type": "AWS::IAM::InstanceProfile",
-            "Properties": {
-                "Path": "/",
-                "Roles": [
-                    {
-                        "Ref": "RootRole"
-                    }
-                ]
+         }
+      },
+      "RestAutoScalingLaunchConfiguration":{
+         "Type":"AWS::AutoScaling::LaunchConfiguration",
+         "Properties":{
+            "UserData":{
+               "Fn::Base64":{
+                  "Fn::Join":[
+                     "",
+                     [
+                        "#!/bin/bash -ex\n",
+                        "# REST SERVER STARTUP \n",
+                        "exec >/var/log/usergrid-bootstrap.log 2>&1\n",
+                        "\n",
+                        "mkdir -p /usr/share/usergrid\n",
+                        "\n",
+                        "# create script that sets our environment variables\n",
+                        "cat >/etc/profile.d/usergrid-env.sh <<EOF\n",
+                        "alias sudo='sudo -E'\n",
+                        "\n",
+                        "export TYPE=rest\n",
+                        "export STACK_NAME=",
+                        {
+                           "Ref":"AWS::StackName"
+                        },
+                        "\n",
+                        "\n",
+                        "export DNS_NAME=",
+                        {
+                           "Ref":"DnsSubDomain"
+                        },
+                        "\n",
+                        "export DNS_DOMAIN=",
+                        {
+                           "Ref":"DnsDomain"
+                        },
+                        "\n",
+                        "export PUBLIC_HOSTNAME=`(curl -s http://169.254.169.254/latest/meta-data/public-hostname)`\n",
+                        "export INTERNAL_HOSTNAME=`(curl http://169.254.169.254/latest/meta-data/local-ipv4)`\n",
+                        "export ELB_NAME=",
+                        {
+                           "Ref":"RestElasticLoadBalancer"
+                        },
+                        "\n",
+                        "\n",
+                        "export EC2_INSTANCE_ID=`ec2metadata --instance-id`\n",
+                        "export EC2_REGION=",
+                        {
+                           "Ref":"AWS::Region"
+                        },
+                        "\n",
+                        "export EC2_URL=https://ec2.amazonaws.com/\n",
+                        "\n",
+                        "export REST_SECURITY_GROUP_NAME=",
+                        {
+                           "Ref":"RestSecurityGroup"
+                        },
+                        "\n",
+                        "export DB_SECURITY_GROUP_NAME=",
+                        {
+                           "Ref":"CassSecurityGroup"
+                        },
+                        "\n",
+                        "\n",
+                        "export CASSANDRA_CLUSTER_NAME=",
+                        {
+                           "Ref":"CassClusterName"
+                        },
+                        "\n",
+                        "export CASSANDRA_KEYSPACE_NAME=usergrid",
+                        "\n",
+                        "export CASSANDRA_NUM_SERVERS=",
+                        {
+                           "Ref":"CassNumServers"
+                        },
+                        "\n",
+                        "export CASSANDRA_REPLICATION_FACTOR=",
+                        {
+                           "Ref":"CassReplicationFactor"
+                        },
+                        "\n",
+                        "\n",
+                        "export RELEASE_BUCKET=",
+                        {
+                           "Ref":"ReleaseBucket"
+                        },
+                        "\n",
+                        "\n",
+                        "export SUPER_USER_EMAIL=",
+                        {
+                           "Ref":"SuperUserEmail"
+                        },
+                        "\n",
+                        "export TEST_ADMIN_USER_EMAIL=",
+                        {
+                           "Ref":"TestAdminUserEmail"
+                        },
+                        "\n",
+                        "\n",
+                        "EOF\n",
+                        "\n",
+                        "# put AWS creds in environment\n",
+                        "cat >/etc/profile.d/aws-credentials.sh <<EOF\n",
+                        "export AWS_ACCESS_KEY=",
+                        {
+                           "Ref":"RestKey"
+                        },
+                        "\n",
+                        "export AWS_SECRET_KEY=",
+                        {
+                           "Fn::GetAtt":[
+                              "RestKey",
+                              "SecretAccessKey"
+                           ]
+                        },
+                        "\n",
+                        "EOF\n",
+                        "\n",
+                        "# setup s3cmd (will be installed by init script) \n",
+                        "cat >/etc/s3cfg <<EOF\n",
+                        "access_key=",
+                        {
+                           "Ref":"RestKey"
+                        },
+                        "\n",
+                        "secret_key=",
+                        {
+                           "Fn::GetAtt":[
+                              "RestKey",
+                              "SecretAccessKey"
+                           ]
+                        },
+                        "\n",
+                        "EOF\n",
+                        "chmod 644 /etc/s3cfg\n",
+                        "ln -s /etc/s3cfg ~ubuntu/.s3cfg\n",
+                        "ln -s /etc/s3cfg ~root/.s3cfg\n",
+                        "\n",
+                        "# download usergrid and init script bundle from S3\n",
+                        "wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | apt-key add -\n",
+                        "wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list\n",
+                        "apt-get update\n",
+                        "apt-get -y install s3cmd\n",
+                        "cd /usr/share/usergrid\n",
+                        "s3cmd --config=/etc/s3cfg get s3://",
+                        {
+                           "Ref":"ReleaseBucket"
+                        },
+                        "/awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "tar xvf awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "rm -fr awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "chmod 755 ./init_instance/*.sh\n",
+                        "cd ./init_instance\n",
+                        "# Init as a REST intance \n",
+                        "sh ./init_rest_server.sh\n"
+                     ]
+                  ]
+               }
+            },
+            "KeyName":{
+               "Ref":"KeyPair"
+            },
+            "ImageId":{
+               "Fn::FindInMap":[
+                  "AWSRegionArch2AMI",
+                  {
+                     "Ref":"AWS::Region"
+                  },
+                  {
+                     "Fn::FindInMap":[
+                        "AWSInstanceType2Arch",
+                        {
+                           "Ref":"RestInstanceType"
+                        },
+                        "Arch"
+                     ]
+                  }
+               ]
+            },
+            "InstanceType":{
+               "Ref":"RestInstanceType"
+            },
+            "IamInstanceProfile":{
+               "Ref":"RootInstanceProfile"
+            },
+            "SecurityGroups":[
+               {
+                  "Ref":"RestSecurityGroup"
+               }
+            ]
+         }
+      },
+      "RestAutoScalingGroup":{
+         "Type":"AWS::AutoScaling::AutoScalingGroup",
+         "Version":"2009-05-15",
+         "Properties":{
+            "AvailabilityZones":[
+               {
+                  "Fn::FindInMap":[
+                     "TwoAZs",
+                     {
+                        "Ref":"AWS::Region"
+                     },
+                     "AZ1"
+                  ]
+               },
+               {
+                  "Fn::FindInMap":[
+                     "TwoAZs",
+                     {
+                        "Ref":"AWS::Region"
+                     },
+                     "AZ2"
+                  ]
+               }
+            ],
+            "LaunchConfigurationName":{
+               "Ref":"RestAutoScalingLaunchConfiguration"
+            },
+            "MinSize":{
+               "Ref":"RestMinServers"
+            },
+            "MaxSize":{
+               "Ref":"RestMaxServers"
+            },
+            "HealthCheckType":"ELB",
+            "HealthCheckGracePeriod":"1800",
+            "LoadBalancerNames":[
+               {
+                  "Ref":"RestElasticLoadBalancer"
+               }
+            ],
+            "NotificationConfiguration":{
+               "TopicARN":{
+                  "Ref":"NotificationTopic"
+               },
+               "NotificationTypes":[
+                  "autoscaling:EC2_INSTANCE_LAUNCH",
+                  "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
+                  "autoscaling:EC2_INSTANCE_TERMINATE",
+                  "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
+               ]
             }
-        },
-        "CassSecurityGroup": {
-            "Type": "AWS::EC2::SecurityGroup",
-            "Properties": {
-                "GroupDescription": "Database Machines",
-                "SecurityGroupIngress": [{
-                        "IpProtocol": "tcp",
-                        "FromPort": "22",
-                        "ToPort": "22",
-                        "CidrIp": "0.0.0.0/0"
-                    }]
+         }
+      },
+      "RestServerScaleUpPolicy":{
+         "Type":"AWS::AutoScaling::ScalingPolicy",
+         "Properties":{
+            "AdjustmentType":"ChangeInCapacity",
+            "AutoScalingGroupName":{
+               "Ref":"RestAutoScalingGroup"
+            },
+            "Cooldown":"60",
+            "ScalingAdjustment":"1"
+         }
+      },
+      "RestServerScaleDownPolicy":{
+         "Type":"AWS::AutoScaling::ScalingPolicy",
+         "Properties":{
+            "AdjustmentType":"ChangeInCapacity",
+            "AutoScalingGroupName":{
+               "Ref":"RestAutoScalingGroup"
+            },
+            "Cooldown":"60",
+            "ScalingAdjustment":"-1"
+         }
+      },
+      "CPUAlarmHigh":{
+         "Type":"AWS::CloudWatch::Alarm",
+         "Properties":{
+            "AlarmDescription":"Scale-up if CPU > 60% for 10 minutes",
+            "MetricName":"CPUUtilization",
+            "Namespace":"AWS/EC2",
+            "Statistic":"Average",
+            "Period":"600",
+            "EvaluationPeriods":"2",
+            "Threshold":"60",
+            "AlarmActions":[
+               {
+                  "Ref":"RestServerScaleUpPolicy"
+               }
+            ],
+            "Dimensions":[
+               {
+                  "Name":"AutoScalingGroupName",
+                  "Value":{
+                     "Ref":"RestAutoScalingGroup"
+                  }
+               }
+            ],
+            "ComparisonOperator":"GreaterThanThreshold"
+         }
+      },
+      "CPUAlarmLow":{
+         "Type":"AWS::CloudWatch::Alarm",
+         "Properties":{
+            "AlarmDescription":"Scale-down if CPU < 10% for 10 minutes",
+            "MetricName":"CPUUtilization",
+            "Namespace":"AWS/EC2",
+            "Statistic":"Average",
+            "Period":"600",
+            "EvaluationPeriods":"2",
+            "Threshold":"10",
+            "AlarmActions":[
+               {
+                  "Ref":"RestServerScaleDownPolicy"
+               }
+            ],
+            "Dimensions":[
+               {
+                  "Name":"AutoScalingGroupName",
+                  "Value":{
+                     "Ref":"RestAutoScalingGroup"
+                  }
+               }
+            ],
+            "ComparisonOperator":"LessThanThreshold"
+         }
+      },
+      "RestElasticLoadBalancer":{
+         "Type":"AWS::ElasticLoadBalancing::LoadBalancer",
+         "Properties":{
+            "AvailabilityZones":[
+               {
+                  "Fn::FindInMap":[
+                     "TwoAZs",
+                     {
+                        "Ref":"AWS::Region"
+                     },
+                     "AZ1"
+                  ]
+               },
+               {
+                  "Fn::FindInMap":[
+                     "TwoAZs",
+                     {
+                        "Ref":"AWS::Region"
+                     },
+                     "AZ2"
+                  ]
+               }
+            ],
+            "Listeners":[
+               {
+                  "LoadBalancerPort":"80",
+                  "InstancePort":"8080",
+                  "Protocol":"HTTP"
+               }
+            ],
+            "HealthCheck":{
+               "Target":"HTTP:8080/status",
+               "HealthyThreshold":"2",
+               "UnhealthyThreshold":"4",
+               "Interval":"30",
+               "Timeout":"5"
             }
-        },
-        "CassSecurityGroupPort7000": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "7000",
-                "ToPort": "7000",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+         }
+      },
+      "NotificationTopic":{
+         "Type":"AWS::SNS::Topic",
+         "Properties":{
+            "Subscription":[
+               {
+                  "Endpoint":{
+                     "Ref":"NotificationEmail"
+                  },
+                  "Protocol":"email"
+               }
+            ]
+         }
+      },
+      "DnsRecord":{
+         "Type":"AWS::Route53::RecordSetGroup",
+         "Properties":{
+            "HostedZoneName":{
+               "Fn::Join":[
+                  ".",
+                  [
+                     {
+                        "Ref":"DnsDomain"
+                     },
+                     ""
+                  ]
+               ]
+            },
+            "RecordSets":[
+               {
+                  "Name":{
+                     "Fn::Join":[
+                        ".",
+                        [
+                           {
+                              "Ref":"DnsSubDomain"
+                           },
+                           {
+                              "Ref":"DnsDomain"
+                           }
+                        ]
+                     ]
+                  },
+                  "Type":"A",
+                  "AliasTarget":{
+                     "HostedZoneId":{
+                        "Fn::GetAtt":[
+                           "RestElasticLoadBalancer",
+                           "CanonicalHostedZoneNameID"
+                        ]
+                     },
+                     "DNSName":{
+                        "Fn::GetAtt":[
+                           "RestElasticLoadBalancer",
+                           "CanonicalHostedZoneName"
+                        ]
+                     }
+                  }
+               }
+            ]
+         }
+      },
+      "RootRole":{
+         "Type":"AWS::IAM::Role",
+         "Properties":{
+            "AssumeRolePolicyDocument":{
+               "Statement":[
+                  {
+                     "Effect":"Allow",
+                     "Principal":{
+                        "Service":[
+                           "ec2.amazonaws.com"
+                        ]
+                     },
+                     "Action":[
+                        "sts:AssumeRole"
+                     ]
+                  }
+               ]
+            },
+            "Path":"/"
+         }
+      },
+      "RolePolicies":{
+         "Type":"AWS::IAM::Policy",
+         "Properties":{
+            "PolicyName":"root",
+            "PolicyDocument":{
+               "Statement":[
+                  {
+                     "Effect":"Allow",
+                     "Action":"*",
+                     "Resource":"*"
+                  }
+               ]
+            },
+            "Roles":[
+               {
+                  "Ref":"RootRole"
+               }
+            ]
+         }
+      },
+      "RootInstanceProfile":{
+         "Type":"AWS::IAM::InstanceProfile",
+         "Properties":{
+            "Path":"/",
+            "Roles":[
+               {
+                  "Ref":"RootRole"
+               }
+            ]
+         }
+      },
+      "CassSecurityGroup":{
+         "Type":"AWS::EC2::SecurityGroup",
+         "Properties":{
+            "GroupDescription":"Database Machines",
+            "SecurityGroupIngress":[
+               {
+                  "IpProtocol":"tcp",
+                  "FromPort":"22",
+                  "ToPort":"22",
+                  "CidrIp":"0.0.0.0/0"
+               }
+            ]
+         }
+      },
+      "CassSecurityGroupPort7000":{
+         "Type":"AWS::EC2::SecurityGroupIngress",
+         "Properties":{
+            "GroupName":{
+               "Ref":"CassSecurityGroup"
+            },
+            "IpProtocol":"tcp",
+            "FromPort":"7000",
+            "ToPort":"7000",
+            "SourceSecurityGroupName":{
+               "Ref":"CassSecurityGroup"
             }
-        },
-        "CassSecurityGroupPort9160": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "9160",
-                "ToPort": "9160",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+         }
+      },
+      "CassSecurityGroupPort9160":{
+         "Type":"AWS::EC2::SecurityGroupIngress",
+         "Properties":{
+            "GroupName":{
+               "Ref":"CassSecurityGroup"
+            },
+            "IpProtocol":"tcp",
+            "FromPort":"9160",
+            "ToPort":"9160",
+            "SourceSecurityGroupName":{
+               "Ref":"CassSecurityGroup"
             }
-        },
-        "RestSecurityGroupPort9160" : {
-                 "Type" : "AWS::EC2::SecurityGroupIngress",
-                 "Properties" : {
-                     "GroupName" : { "Ref" : "CassSecurityGroup" },
-                     "IpProtocol": "tcp",
-                    "FromPort": "9160",
-                    "ToPort": "9160",
-                    "SourceSecurityGroupName": {"Ref": "RestSecurityGroup"}
-                 }
-             },
-        "CassSecurityGroupPort9200": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "9200",
-                "ToPort": "9200",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+         }
+      },
+      "RestSecurityGroupPort9160":{
+         "Type":"AWS::EC2::SecurityGroupIngress",
+         "Properties":{
+            "GroupName":{
+               "Ref":"CassSecurityGroup"
+            },
+            "IpProtocol":"tcp",
+            "FromPort":"9160",
+            "ToPort":"9160",
+            "SourceSecurityGroupName":{
+               "Ref":"RestSecurityGroup"
             }
-        },
-        "CassSecurityGroupPort9300": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "9300",
-                "ToPort": "9300",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+         }
+      },
+      "CassSecurityGroupPort9200":{
+         "Type":"AWS::EC2::SecurityGroupIngress",
+         "Properties":{
+            "GroupName":{
+               "Ref":"CassSecurityGroup"
+            },
+            "IpProtocol":"tcp",
+            "FromPort":"9200",
+            "ToPort":"9200",
+            "SourceSecurityGroupName":{
+               "Ref":"CassSecurityGroup"
             }
-        },
-        "RestSecurityGroup": {
-            "Type": "AWS::EC2::SecurityGroup",
-            "Properties": {
-                "GroupDescription": "REST Machines",
-                "SecurityGroupIngress": [{
-                        "IpProtocol": "tcp",
-                        "FromPort": "22",
-                        "ToPort": "22",
-                        "CidrIp": "0.0.0.0/0"
-                    }, {
-                        "IpProtocol": "tcp",
-                        "FromPort": "8080",
-                        "ToPort": "8080",
-                        "CidrIp": "0.0.0.0/0"
-                    }]
+         }
+      },
+      "CassSecurityGroupPort9300":{
+         "Type":"AWS::EC2::SecurityGroupIngress",
+         "Properties":{
+            "GroupName":{
+               "Ref":"CassSecurityGroup"
+            },
+            "IpProtocol":"tcp",
+            "FromPort":"9300",
+            "ToPort":"9300",
+            "SourceSecurityGroupName":{
+               "Ref":"CassSecurityGroup"
             }
-        }
-    }
-
-
-
+         }
+      },
+      "RestSecurityGroup":{
+         "Type":"AWS::EC2::SecurityGroup",
+         "Properties":{
+            "GroupDescription":"REST Machines",
+            "SecurityGroupIngress":[
+               {
+                  "IpProtocol":"tcp",
+                  "FromPort":"22",
+                  "ToPort":"22",
+                  "CidrIp":"0.0.0.0/0"
+               },
+               {
+                  "IpProtocol":"tcp",
+                  "FromPort":"8080",
+                  "ToPort":"8080",
+                  "CidrIp":"0.0.0.0/0"
+               }
+            ]
+         }
+      }
+   }
 }


Mime
View raw message