Skip to content

Instantly share code, notes, and snippets.

@stojg
Created November 14, 2014 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stojg/5b75f9ca0abe34c3aaa4 to your computer and use it in GitHub Desktop.
Save stojg/5b75f9ca0abe34c3aaa4 to your computer and use it in GitHub Desktop.
CoreOS On AWS Cloudformation
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/",
"Mappings" : {
"RegionMap" : {
"eu-central-1" : { "AMI" : "ami-e8c6f0f5" },
"ap-northeast-1" : { "AMI" : "ami-858eb884" },
"sa-east-1" : { "AMI" : "ami-7b922666" },
"ap-southeast-2" : { "AMI" : "ami-13abc629" },
"ap-southeast-1" : { "AMI" : "ami-7e78592c" },
"us-east-1" : { "AMI" : "ami-da78c3b2" },
"us-west-2" : { "AMI" : "ami-e32965d3" },
"us-west-1" : { "AMI" : "ami-876772c2" },
"eu-west-1" : { "AMI" : "ami-46e14e31" }
}
},
"Parameters": {
"InstanceType" : {
"Description" : "EC2 PV instance type (m3.medium, etc). Note: m1.small is not supported.",
"Type" : "String",
"Default" : "m3.medium",
"AllowedValues" : ["m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "m1.medium", "m1.large", "m1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c1.medium", "c1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "hi1.4xlarge", "hs1.8xlarge", "t1.micro"],
"ConstraintDescription" : "Must be a valid EC2 PV instance type. Note: m1.small is not supported."
},
"ClusterSize": {
"Default": "3",
"MinValue": "3",
"MaxValue": "12",
"Description": "Number of nodes in cluster (3-12).",
"Type": "Number"
},
"Client": {
"Description": "The VPC Id to deploy Core OS into",
"Type": "String"
},
"DiscoveryURL": {
"Description": "An unique etcd cluster discovery URL. Grab a new token from https://discovery.etcd.io/new",
"Type": "String"
},
"AdvertisedIPAddress": {
"Description": "Use 'private' if your etcd cluster is within one region or 'public' if it spans regions or cloud providers.",
"Default": "private",
"AllowedValues": ["private", "public"],
"Type": "String"
},
"AllowSSHFrom": {
"Description": "The net block (CIDR) that SSH is available to.",
"Default": "0.0.0.0/0",
"Type": "String"
},
"KeyPair" : {
"Description" : "The name of an EC2 Key Pair to allow SSH access to the instance.",
"Type" : "String"
},
"AvailabilityZone1" : {
"Description" : "First AZ to use for PublicSubnet1/PrivateSubnet1.",
"Type" : "String",
"Default" : "ap-southeast-2a"
},
"AvailabilityZone2" : {
"Description" : "Second AZ to use for PublicSubnet2/PrivateSubnet2.",
"Type" : "String",
"Default" : "ap-southeast-2b"
}
},
"Resources": {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "10.10.0.0/20",
"Tags" : [
{ "Key": "Name", "Value" : {"Fn::Join": ["", [{ "Ref": "Client" }, ".vpc"]] } },
{ "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
{ "Key" : "ss:client", "Value" : { "Ref": "Client"} }
]
}
},
"Subnet01" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"AvailabilityZone" : { "Ref" : "AvailabilityZone1" },
"CidrBlock" : "10.10.0.0/24",
"Tags" : [
{ "Key": "Name", "Value" : {"Fn::Join": ["", [{ "Ref": "Client" }, ".public.subnet.az2a.1"]] } },
{ "Key" : "Type", "Value" : "Subnet" },
{ "Key" : "Network", "Value" : "Public" },
{ "Key" : "ss:client", "Value" : { "Ref": "Client"} }
]
}
},
"Subnet02" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"AvailabilityZone" : { "Ref" : "AvailabilityZone2" },
"CidrBlock" : "10.10.1.0/24",
"Tags" : [
{ "Key": "Name", "Value" : {"Fn::Join": ["", [{ "Ref": "Client" }, ".public.subnet.az2b.1"]] } },
{ "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
{ "Key" : "Network", "Value" : "Public" },
{ "Key" : "ss:client", "Value" : { "Ref": "Client"} }
]
}
},
"InternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [
{ "Key": "Name", "Value" : {"Fn::Join": ["", [{ "Ref": "Client" }, ".ig"]] } },
{ "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
{ "Key" : "Network", "Value" : "Public" },
{ "Key" : "ss:client", "Value" : { "Ref": "Client"} }
]
}
},
"GatewayToInternet" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"InternetGatewayId" : { "Ref" : "InternetGateway" }
}
},
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"Tags" : [
{ "Key": "Name", "Value" : {"Fn::Join": ["", [{ "Ref": "Client" }, ".public.routetable.1"]] } },
{ "Key" : "ss:client", "Value" : { "Ref": "Client"} },
{ "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
{ "Key" : "Network", "Value" : "Public" }
]
}
},
"PublicRoute" : {
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "PublicRouteTable" },
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : { "Ref" : "InternetGateway" }
}
},
"Subnet01RTAssoc" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "Subnet01" },
"RouteTableId" : { "Ref" : "PublicRouteTable" }
}
},
"Subnet02RTAssoc" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "Subnet02" },
"RouteTableId" : { "Ref" : "PublicRouteTable" }
}
},
"CoreOSSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"VpcId": { "Ref": "VPC" },
"GroupDescription": "CoreOS SecurityGroup",
"SecurityGroupIngress": [
{"IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": {"Ref": "AllowSSHFrom"}},
{"IpProtocol": "tcp", "FromPort": "10000", "ToPort": "65535", "CidrIp": {"Ref": "AllowSSHFrom"}}
]
}
},
"Ingress4001": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ] }, "IpProtocol": "tcp", "FromPort": "4001", "ToPort": "4001", "SourceSecurityGroupId": {
"Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ]
}
}
},
"Ingress7001": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ] }, "IpProtocol": "tcp", "FromPort": "7001", "ToPort": "7001", "SourceSecurityGroupId": {
"Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ]
}
}
},
"CoreOSServerAutoScale": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": {"Fn::GetAZs": ""},
"VPCZoneIdentifier" : [ {"Ref": "Subnet01"}, {"Ref": "Subnet02"} ],
"LaunchConfigurationName": {"Ref": "CoreOSServerLaunchConfig"},
"MinSize": "3",
"MaxSize": "12",
"DesiredCapacity": {"Ref": "ClusterSize"},
"Tags": [
{"Key": "Name", "Value": { "Ref" : "AWS::StackName" }, "PropagateAtLaunch": true}
]
}
},
"CoreOSServerLaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"AssociatePublicIpAddress": "true",
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"InstanceType": {"Ref": "InstanceType"},
"KeyName": {"Ref": "KeyPair"},
"SecurityGroups": [{"Ref": "CoreOSSecurityGroup"}],
"UserData" : { "Fn::Base64":
{ "Fn::Join": [ "", [
"#cloud-config\n\n",
"coreos:\n",
" etcd:\n",
" discovery: ", { "Ref": "DiscoveryURL" }, "\n",
" addr: $", { "Ref": "AdvertisedIPAddress" }, "_ipv4:4001\n",
" peer-addr: $", { "Ref": "AdvertisedIPAddress" }, "_ipv4:7001\n",
" units:\n",
" - name: etcd.service\n",
" command: start\n",
" - name: fleet.service\n",
" command: start\n"
] ]
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment