Skip to content

Instantly share code, notes, and snippets.

@usmanismail
Forked from bilal/seyren_cloudfront.json
Last active December 19, 2015 07:59
Show Gist options
  • Save usmanismail/5922231 to your computer and use it in GitHub Desktop.
Save usmanismail/5922231 to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template creates a seyren application. The template uses the WaitCondition resource to synchronize creation of the stack with the application becoming healthy. **WARNING** This template creates an Amazon EC2 instance and an Elastic IP Address. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type" : "String"
},
"GraphiteUrl" : {
"Description" : "The graphite url where you want to load data from",
"Type" : "String"
},
"GraphiteUsername" : {
"Description" : "The graphite username if authentication is used. Default: ``",
"Type" : "String",
"Default" : ""
},
"GraphitePassword" : {
"Description" : "The graphite server password if authentication is used. Default: ``",
"Type" : "String",
"Default" : ""
},
"SeyrenUrl" : {
"Description" : "The location of your seyren instance. Default: http://localhost:8080/seyren",
"Type" : "String",
"Default" : "http://localhost:8080/seyren"
},
"SeyrenFromEmail" : {
"Description" : "The from email address for sending out alerts. Default: alert@seyren",
"Type" : "String",
"Default" : "alert@seyren"
},
"MongoUrl" : {
"Description" : "The mongo connection string. Default: mongodb://localhost:27017/seyren",
"Type" : "String",
"Default" : "mongodb://localhost:27017/seyren"
},
"SmtpHost" : {
"Description" : "The smtp server to send email notifications from. Default: localhost",
"Type" : "String",
"Default" : "localhost"
},
"SmtpPort" : {
"Description" : "The smtp server port. Default: 25",
"Type" : "String",
"Default" : "25"
},
"SmtpUsername" : {
"Description" : "The smtp server username if authenticated SMTP is used. Default: ``",
"Type" : "String",
"Default" : ""
},
"SmtpPassword" : {
"Description" : "The smtp server password if authenticated SMTP is used. Default: ``",
"Type" : "String",
"Default" : ""
},
"InstanceType" : {
"Description" : "WebServer 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","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge"],
"ConstraintDescription" : "must be a valid EC2 instance type."
}
},
"Mappings" : {
"AWSInstanceType2Arch" : {
"t1.micro" : { "Arch" : "64" },
"m1.small" : { "Arch" : "64" },
"m1.medium" : { "Arch" : "64" },
"m1.large" : { "Arch" : "64" },
"m1.xlarge" : { "Arch" : "64" },
"m2.xlarge" : { "Arch" : "64" },
"m2.2xlarge" : { "Arch" : "64" },
"m2.4xlarge" : { "Arch" : "64" },
"c1.medium" : { "Arch" : "64" },
"c1.xlarge" : { "Arch" : "64" },
"cc1.4xlarge" : { "Arch" : "64HVM" },
"cc2.8xlarge" : { "Arch" : "64HVM" },
"cg1.4xlarge" : { "Arch" : "64HVM" }
},
"AWSRegionArch2AMI" : {
"us-east-1" : { "32" : "ami-31814f58", "64" : "ami-1b814f72", "64HVM" : "ami-0da96764" },
"us-west-2" : { "32" : "ami-38fe7308", "64" : "ami-30fe7300", "64HVM" : "NOT_YET_SUPPORTED" },
"us-west-1" : { "32" : "ami-11d68a54", "64" : "ami-1bd68a5e", "64HVM" : "NOT_YET_SUPPORTED" },
"eu-west-1" : { "32" : "ami-973b06e3", "64" : "ami-953b06e1", "64HVM" : "NOT_YET_SUPPORTED" },
"ap-southeast-1" : { "32" : "ami-b4b0cae6", "64" : "ami-beb0caec", "64HVM" : "NOT_YET_SUPPORTED" },
"ap-northeast-1" : { "32" : "ami-0644f007", "64" : "ami-0a44f00b", "64HVM" : "NOT_YET_SUPPORTED" },
"sa-east-1" : { "32" : "ami-3e3be423", "64" : "ami-3c3be421", "64HVM" : "NOT_YET_SUPPORTED" }
}
},
"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"KeyName" : { "Ref" : "KeyName" },
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
"InstanceType" : { "Ref" : "InstanceType" },
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["",[
"#!/bin/bash -ex","\n",
"exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1","\n",
"wget -O seyren_setup.sh https://gist.github.com/bilal/5919452/raw/b7c9edb4426e1b2fd7d08b9b990a0aa7cdf36d95/seyren-setup.sh\n",
"chmod +x seyren-setup.sh\n",
"./seyren-setup.sh\n",
"#### Start Seyren ####\n",
"export GRAPHITE_URL=", {"Ref" : "GraphiteUrl"}, "\n",
"export GRAPHITE_USERNAME=", {"Ref" : "GraphiteUsername"}, "\n",
"export GRAPHITE_PASSWORD=", {"Ref" : "GraphitePassword"}, "\n",
"export SEYREN_URL=", {"Ref" : "SeyrenUrl"}, "\n",
"export SEYREN_FROM_EMAIL=", {"Ref" : "SeyrenFromEmail"}, "\n",
"export MONGO_URL=", {"Ref" : "MongoUrl"}, "\n",
"export SMTP_HOST=", {"Ref" : "SmtpHost"}, "\n",
"export SMTP_PORT=", {"Ref" : "SmtpPort"}, "\n",
"export SMTP_USERNAME=", {"Ref" : "SmtpUsername"}, "\n",
"export SMTP_PASSWORD=", {"Ref" : "SmtpPassword"}, "\n",
"curl -X PUT -H 'Content-Type:' --data-binary '{\"Status\" : \"SUCCESS\",",
"\"Reason\" : \"Seyren is ready\",",
"\"UniqueId\" : \"Seyren\",",
"\"Data\" : \"Done\"}' ",
"\"", {"Ref" : "WaitForInstanceWaitHandle"},"\"\n",
"chown -R ec2-user:ec2-user /opt/scobal-seyren-*\n",
"su ec2-user\n",
"cd ~/\n",
"wget -O seyren_restart.sh https://gist.github.com/bilal/5825908/raw/fcfb0aa4e1b2d7c15a665f9999885262f20640dd/seyren_restart.sh\n",
"chmod +x seyren_restart.sh\n",
"./seyren_restart.sh\n",
"sudo cp seyren_restart.sh /etc/cron.daily/\n"
]]}}
}
},
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable Access to Seyren via port 8080 and SSH access via port 22",
"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" }
]
}
},
"WaitForInstanceWaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle",
"Properties" : {
}
},
"WaitForInstance" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn" : "Ec2Instance",
"Properties" : {
"Handle" : {"Ref" : "WaitForInstanceWaitHandle"},
"Timeout" : "600"
}
}
},
"Outputs" : {
"WebsiteURL" : {
"Description" : "The URL for the newly created Seyren Server",
"Value" : { "Fn::Join" : ["", [ "http://", { "Fn::GetAtt" : [ "Ec2Instance", "PublicDnsName" ] }, ":8080/seyren" ]]}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment