Skip to content

Instantly share code, notes, and snippets.

@sjudeng
Created May 6, 2017 13:45
Show Gist options
  • Save sjudeng/32821da2ec85fd36de51bf237b5a258a to your computer and use it in GitHub Desktop.
Save sjudeng/32821da2ec85fd36de51bf237b5a258a to your computer and use it in GitHub Desktop.
CloudFormation template with CentOS 7 for JanusGraph testing
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Create an Amazon EC2 instance running the CentOS 7 AMI. Install JanusGraph.",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
},
"InstanceType" : {
"Description" : "Host EC2 instance type",
"Type" : "String",
"Default" : "t2.small",
"AllowedValues" : [ "t1.micro", "t2.nano", "t2.micro", "t2.small", "t2.medium", "t2.large", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "g2.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"]
,
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"VolumeSize" : {
"Description" : "Size for EBS volume attachment",
"Type" : "Number",
"Default" : "50"
},
"SSHLocation" : {
"Description" : "The IP address range that can be used to SSH to the EC2 instances",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
}
},
"Mappings" : {
"RegionMap":{
"us-east-1":{
"CentOS7x8664withUpdatesHVM":"ami-6d1c2007"
},
"us-west-2":{
"CentOS7x8664withUpdatesHVM":"ami-d2c924b2"
},
"us-west-1":{
"CentOS7x8664withUpdatesHVM":"ami-af4333cf"
},
"eu-central-1":{
"CentOS7x8664withUpdatesHVM":"ami-9bf712f4"
},
"eu-west-1":{
"CentOS7x8664withUpdatesHVM":"ami-7abd0209"
},
"ap-southeast-1":{
"CentOS7x8664withUpdatesHVM":"ami-f068a193"
},
"ap-southeast-2":{
"CentOS7x8664withUpdatesHVM":"ami-fedafc9d"
},
"ap-northeast-1":{
"CentOS7x8664withUpdatesHVM":"ami-eec1c380"
},
"ap-northeast-2":{
"CentOS7x8664withUpdatesHVM":"ami-c74789a9"
},
"sa-east-1":{
"CentOS7x8664withUpdatesHVM":"ami-26b93b4a"
}
}
},
"Resources" : {
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"InstanceType" : { "Ref" : "InstanceType" },
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
"KeyName" : { "Ref" : "KeyName" },
"ImageId":{
"Fn::FindInMap":[
"RegionMap",
{
"Ref":"AWS::Region"
},
"CentOS7x8664withUpdatesHVM"
]
},
"Tags" : [
{
"Key" : "Name",
"Value" : {"Ref" : "AWS::StackName"}
}
],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y\n",
"yum install -y vim unzip zip wget git java-1.8.0-openjdk-devel maven\n",
"su -c \"git clone https://github.com/apache/tinkerpop.git tinkerpop\" - centos\n",
"su -c \"git clone https://github.com/janusgraph/janusgraph.git janusgraph\" - centos\n"
]]}},
"BlockDeviceMappings": [{
"DeviceName": "/dev/sda1",
"Ebs" : { "VolumeSize" : { "Ref" : "VolumeSize"}}
}]
}
},
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access via port 22",
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : { "Ref" : "SSHLocation"}
}
]
}
}
},
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "EC2Instance" }
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "AvailabilityZone" ] }
},
"PublicDNS" : {
"Description" : "Public DNSName of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PublicDnsName" ] }
},
"PublicIP" : {
"Description" : "Public IP address of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "EC2Instance", "PublicIp" ] }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment