Skip to content

Instantly share code, notes, and snippets.

@tuppa
Created March 20, 2014 02:06
Show Gist options
  • Save tuppa/9655843 to your computer and use it in GitHub Desktop.
Save tuppa/9655843 to your computer and use it in GitHub Desktop.
Updated CoreOS CloudFormation template - to use SourceSecurityGroupId in the ingress rules
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/ec2/",
"Mappings" : {
"RegionMap" : {
"ap-northeast-1" : {
"AMI" : "ami-ef1f6eee"
},
"sa-east-1" : {
"AMI" : "ami-0145e61c"
},
"ap-southeast-2" : {
"AMI" : "ami-6b5bc251"
},
"ap-southeast-1" : {
"AMI" : "ami-54b4e506"
},
"us-east-1" : {
"AMI" : "ami-8f0a06e6"
},
"us-west-2" : {
"AMI" : "ami-d66906e6"
},
"us-west-1" : {
"AMI" : "ami-d839069d"
},
"eu-west-1" : {
"AMI" : "ami-1fef1268"
}
}
},
"Parameters": {
"InstanceType" : {
"Description" : "EC2 instance type (m1.small, etc).",
"Type" : "String",
"Default" : "t1.micro",
"AllowedValues" : [ "t1.micro",
"m1.small",
"m1.medium",
"m1.large",
"m1.xlarge",
"m3.xlarge",
"m3.2xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"c1.medium",
"c1.xlarge",
"cc1.4xlarge",
"cc2.8xlarge",
"cg1.4xlarge",
"hi1.4xlarge",
"hs1.8xlarge"],
"ConstraintDescription" : "must be a valid EC2 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"
},
"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"
}
},
"Resources": {
"CoreOSSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "CoreOS SecurityGroup",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": {
"Ref": "AllowSSHFrom"
}
}
]
}
},
"Ingress4001": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupName": {
"Ref": "CoreOSSecurityGroup"
},
"IpProtocol": "tcp",
"FromPort": "4001",
"ToPort": "4001",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ]
}
}
},
"Ingress7001": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupName": {
"Ref": "CoreOSSecurityGroup"
},
"IpProtocol": "tcp",
"FromPort": "7001",
"ToPort": "7001",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "CoreOSSecurityGroup", "GroupId" ]
}
}
},
"CoreOSServerAutoScale": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": {
"Fn::GetAZs": ""
},
"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": {
"ImageId" : {
"Fn::FindInMap" : [ "RegionMap",
{
"Ref" : "AWS::Region"
},
"AMI" ]
},
"InstanceType": {
"Ref": "InstanceType"
},
"KeyName": {
"Ref": "KeyPair"
},
"SecurityGroups": [{
"Ref": "CoreOSSecurityGroup"
}],
"UserData" : {
"Fn::Base64" : {
"Fn::Join" : ["",
[
"#!/bin/sh\n",
"ETCD_DISCOVERY_URL=",
{
"Ref" : "DiscoveryURL"
},
"\n",
"START_FLEET=1\n"
]
]
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment