Skip to content

Instantly share code, notes, and snippets.

@johngian
Last active September 30, 2015 16:55
Show Gist options
  • Save johngian/52563fdadaf7a7388028 to your computer and use it in GitHub Desktop.
Save johngian/52563fdadaf7a7388028 to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Launches a cluster to facilitate as HA Mesos cluster",
"Parameters": {
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "String"
}
},
"Resources": {
"MesosVPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"Tags": [{"Key" : "name", "Value" : "mesos-cluster-vpc"}]
}
},
"MesosPublicSubnet": {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "MesosVPC" },
"CidrBlock" : "10.0.0.0/24",
"AvailabilityZone" : "us-west-2a",
"Tags" : [ { "Key" : "name", "Value" : "mesos-public-subnet" } ]
}
},
"MesosInternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [ {"Key" : "name", "Value" : "mesos-internet-gateway"}]
}
},
"AttachMesosGateway": {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : { "Ref" : "MesosVPC" },
"InternetGatewayId" : { "Ref" : "MesosInternetGateway" }
}
},
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : { "Ref" : "MesosVPC" }
}
},
"PublicRoute" : {
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "PublicRouteTable" },
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : { "Ref" : "MesosInternetGateway" }
}
},
"PublicSubnetRouteTableAssociation" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "MesosPublicSubnet" },
"RouteTableId" : { "Ref" : "PublicRouteTable" }
}
},
"HTTPonly": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow http/https access",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp" : "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort": "443",
"ToPort": "443",
"CidrIp" : "0.0.0.0/0"
}
],
"VpcId": { "Ref": "MesosVPC"},
"Tags": [
{"Key": "Name", "Value": "mesos-cluster-base"}
]
}
},
"MesosCommonSG": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow ssh access to all mesos cluster nodes",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp" : "0.0.0.0/0"
}
],
"VpcId": { "Ref": "MesosVPC"},
"Tags": [
{"Key": "Name", "Value": "mesos-cluster-base"}
]
}
},
"MesosMasterSG": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow inbound access to mesos-master/marathon web interfaces",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"FromPort": "8000",
"ToPort": "8000",
"CidrIp" : "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort": "8080",
"ToPort": "8080",
"CidrIp" : "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort": "5050",
"ToPort": "5050",
"CidrIp" : "0.0.0.0/0"
}
],
"VpcId": { "Ref": "MesosVPC"},
"Tags": [
{"Key": "Name", "Value": "mesos-cluster-master"}
]
}
},
"MesosSlaveSG": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow traffic to docker containers in mesos-slave nodes.",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"FromPort": "31000",
"ToPort": "32000",
"CidrIp" : "0.0.0.0/0"
}
],
"VpcId": { "Ref": "MesosVPC"},
"Tags": [
{"Key": "Name", "Value": "mesos-cluster-slave"}
]
}
},
"MesosClusterInternalTCP": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": {
"Fn::GetAtt": ["MesosCommonSG", "GroupId"]
},
"IpProtocol": "tcp",
"FromPort": "0",
"ToPort": "65535",
"SourceSecurityGroupId": {
"Fn::GetAtt": ["MesosCommonSG", "GroupId"]
}
}
},
"MesosClusterInternalUDP": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": {
"Fn::GetAtt": ["MesosCommonSG", "GroupId"]
},
"IpProtocol": "udp",
"FromPort": "0",
"ToPort": "65535",
"SourceSecurityGroupId": {
"Fn::GetAtt": ["MesosCommonSG", "GroupId"]
}
}
},
"MesosMaster1": {
"Properties": {
"ImageId": "ami-5189a661",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds" : [
{"Fn::GetAtt": ["MesosCommonSG", "GroupId"]},
{"Fn::GetAtt": ["MesosMasterSG", "GroupId"]}
],
"SubnetId": {
"Ref": "MesosPublicSubnet"
},
"PrivateIpAddress": "10.0.0.1",
"Tags": [
{"Key": "Name", "Value": "mesos-master1"},
{"Key": "Purpose", "Value": "master-node"}
]
},
"Type": "AWS::EC2::Instance"
},
"MesosMaster2": {
"Properties": {
"ImageId": "ami-5189a661",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds" : [
{"Fn::GetAtt": ["MesosCommonSG", "GroupId"]},
{"Fn::GetAtt": ["MesosMasterSG", "GroupId"]}
],
"SubnetId": {
"Ref": "MesosPublicSubnet"
},
"PrivateIpAddress": "10.0.0.2",
"Tags": [
{"Key": "Name", "Value": "mesos-master2"},
{"Key": "Purpose", "Value": "master-node"}
]
},
"Type": "AWS::EC2::Instance"
},
"MesosMaster3": {
"Properties": {
"ImageId": "ami-5189a661",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds" : [
{"Fn::GetAtt": ["MesosCommonSG", "GroupId"]},
{"Fn::GetAtt": ["MesosMasterSG", "GroupId"]}
],
"SubnetId": {
"Ref": "MesosPublicSubnet"
},
"PrivateIpAddress": "10.0.0.3",
"Tags": [
{"Key": "Name", "Value": "mesos-master3"},
{"Key": "Purpose", "Value": "master-node"}
]
},
"Type": "AWS::EC2::Instance"
},
"MesosSlave1": {
"Properties": {
"ImageId": "ami-5189a661",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds" : [
{"Fn::GetAtt": ["MesosCommonSG", "GroupId"]},
{"Fn::GetAtt": ["MesosSlaveSG", "GroupId"]}
],
"SubnetId": {
"Ref": "MesosPublicSubnet"
},
"PrivateIpAddress": "10.0.0.4",
"Tags": [
{"Key": "Name", "Value": "mesos-slave1"},
{"Key": "Purpose", "Value": "slave-node"}
]
},
"Type": "AWS::EC2::Instance"
},
"MesosSlave2": {
"Properties": {
"ImageId": "ami-5189a661",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds" : [
{"Fn::GetAtt": ["MesosCommonSG", "GroupId"]},
{"Fn::GetAtt": ["MesosSlaveSG", "GroupId"]}
],
"SubnetId": {
"Ref": "MesosPublicSubnet"
},
"PrivateIpAddress": "10.0.0.5",
"Tags": [
{"Key": "Name", "Value": "mesos-slave2"},
{"Key": "Purpose", "Value": "slave-node"}
]
},
"Type": "AWS::EC2::Instance"
},
"MesosSlave3": {
"Properties": {
"ImageId": "ami-5189a661",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroupIds" : [
{"Fn::GetAtt": ["MesosCommonSG", "GroupId"]},
{"Fn::GetAtt": ["MesosSlaveSG", "GroupId"]}
],
"SubnetId": {
"Ref": "MesosPublicSubnet"
},
"PrivateIpAddress": "10.0.0.6",
"Tags": [
{"Key": "Name", "Value": "mesos-slave3"},
{"Key": "Purpose", "Value": "slave-node"}
]
},
"Type": "AWS::EC2::Instance"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment