Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save christian-blades-cb/b56041486c4de00d437d to your computer and use it in GitHub Desktop.
Save christian-blades-cb/b56041486c4de00d437d to your computer and use it in GitHub Desktop.
Cloudformation for launching CoreOS inside a VPC
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/",
"Mappings" : {
"RegionMap" : {
"eu-central-1" : {
"AMI" : "ami-448dbd59"
},
"ap-northeast-1" : {
"AMI" : "ami-0a05160b"
},
"sa-east-1" : {
"AMI" : "ami-27b00d3a"
},
"ap-southeast-2" : {
"AMI" : "ami-b5295c8f"
},
"ap-southeast-1" : {
"AMI" : "ami-ba0f27e8"
},
"us-east-1" : {
"AMI" : "ami-3e750856"
},
"us-west-2" : {
"AMI" : "ami-bf2d728f"
},
"us-west-1" : {
"AMI" : "ami-8f534dca"
},
"eu-west-1" : {
"AMI" : "ami-e76dec90"
}
}
},
"Parameters": {
"InstanceType" : {
"Description" : "EC2 PV instance type (m3.medium, etc).",
"Type" : "String",
"Default" : "m3.medium",
"ConstraintDescription" : "Must be a valid EC2 PV instance type."
},
"ClusterSize": {
"Default": "3",
"MinValue": "3",
"MaxValue": "12",
"Description": "Number of nodes in cluster (3-12).",
"Type": "Number"
},
"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" : "AWS::EC2::KeyPair::KeyName"
},
"MyVPC": {
"Description": "VPC in which to launch the cluster.",
"Type": "AWS::EC2::VPC::Id"
},
"SubnetId": {
"Type": "List<AWS::EC2::Subnet::Id>",
"Description": "Subnets in which to launch instances."
},
"SubnetAZs": {
"Default": "us-east-1a,us-east-1c",
"Type": "CommaDelimitedList",
"Description": "AZ(s) that your Subnet(s) support"
}
},
"Resources": {
"CoreOSSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "CoreOS SecurityGroup",
"VpcId": { "Ref": "MyVPC" },
"SecurityGroupIngress": [
{"IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "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": {
"LaunchConfigurationName": {"Ref": "CoreOSServerLaunchConfig"},
"VPCZoneIdentifier": {"Ref": "SubnetId"},
"AvailabilityZones": { "Ref": "SubnetAZs" },
"MinSize": "3",
"MaxSize": "12",
"DesiredCapacity": {"Ref": "ClusterSize"},
"Tags": [
{"Key": "Name", "Value": { "Ref" : "AWS::StackName" }, "PropagateAtLaunch": true}
]
}
},
"CoreOSServerLaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"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