{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "CoreOSSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "SecurityGroupIngress": [ { "ToPort": "22", "IpProtocol": "tcp", "CidrIp": { "Ref": "AllowSSHFrom" }, "FromPort": "22" } ], "GroupDescription": "CoreOS SecurityGroup" } }, "Ingress7001": { "Type": "AWS::EC2::SecurityGroupIngress", "Properties": { "ToPort": "7001", "GroupName": { "Ref": "CoreOSSecurityGroup" }, "SourceSecurityGroupId": { "Fn::GetAtt": [ "CoreOSSecurityGroup", "GroupId" ] }, "FromPort": "7001", "IpProtocol": "tcp" } }, "Ingress4001": { "Type": "AWS::EC2::SecurityGroupIngress", "Properties": { "ToPort": "4001", "GroupName": { "Ref": "CoreOSSecurityGroup" }, "SourceSecurityGroupId": { "Fn::GetAtt": [ "CoreOSSecurityGroup", "GroupId" ] }, "FromPort": "4001", "IpProtocol": "tcp" } }, "PfsIngress": { "Type": "AWS::EC2::SecurityGroupIngress", "Properties": { "ToPort": "65535", "GroupName": { "Ref": "CoreOSSecurityGroup" }, "SourceSecurityGroupId": { "Fn::GetAtt": [ "CoreOSSecurityGroup", "GroupId" ] }, "FromPort": "49153", "IpProtocol": "tcp" } }, "CoreOSServerAutoScale": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "DesiredCapacity": { "Ref": "ClusterSize" }, "Tags": [ { "PropagateAtLaunch": true, "Value": { "Ref": "AWS::StackName" }, "Key": "Name" } ], "MinSize": "3", "MaxSize": "500", "LaunchConfigurationName": { "Ref": "CoreOSServerLaunchConfig" }, "AvailabilityZones": { "Fn::GetAZs": "" } } }, "CoreOSServerLaunchConfig": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { "BlockDeviceMappings" : [ { "DeviceName" : "/dev/xvdf", "Ebs" : { "VolumeSize" : { "Ref" : "VolSize" }, "VolumeType" : { "Ref" : "VolType" } } } ], "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", " - name: deploy.service\n", " command: start\n", " content: |\n", " [Unit]\n", " Description = pachyderm service: router\n", " After = docker.service fleet.service\n", " Requires = docker.service fleet.service\n", " [Service]\n", " Type = oneshot\n", " RemainAfterExit = yes\n", " ExecStartPre = /bin/sh -c 'echo $(mkdir -p /tmp/home/core/pfs)'\n", " ExecStartPre = /bin/sh -c 'echo $(sudo docker run", " --privileged=true ", " -v /:/host:ro", " -v /tmp/home/core:/host/home/core", " pachyderm/deploy", " -disk /dev/xvdf ", { "Ref" : "PfsDeployArgs" }, " )'\n", " ExecStart = /bin/sh -c 'echo $(fleetctl start /tmp/home/core/pfs/*.service)'\n" ] ] } }, "KeyName": { "Ref": "KeyPair" }, "SecurityGroups": [ { "Ref": "CoreOSSecurityGroup" } ], "InstanceType": { "Ref": "InstanceType" }, "ImageId": { "Fn::FindInMap": [ "RegionMap", { "Ref": "AWS::Region" }, "AMI" ] } } } }, "Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/", "Parameters": { "AllowSSHFrom": { "Default": "0.0.0.0/0", "Type": "String", "Description": "The net block (CIDR) that SSH is available to." }, "DiscoveryURL": { "Type": "String", "Description": "An unique etcd cluster discovery URL. Grab a new token from https://discovery.etcd.io/new" }, "ClusterSize": { "Default": "3", "Description": "Number of nodes in cluster (3-500).", "Type": "Number", "MaxValue": "500", "MinValue": "3" }, "AdvertisedIPAddress": { "Default": "private", "Type": "String", "Description": "Use 'private' if your etcd cluster is within one region or 'public' if it spans regions or cloud providers.", "AllowedValues": [ "private", "public" ] }, "KeyPair": { "Type": "String", "Description": "The name of an EC2 Key Pair to allow SSH access to the instance." }, "InstanceType": { "Default": "m3.medium", "ConstraintDescription": "Must be a valid EC2 HVM instance type.", "Type": "String", "Description": "EC2 HVM instance type (m3.medium, etc)." }, "PfsDeployArgs": { "Type": "String", "Description": "Usage: -shards s -replicas r.", "Default": "-shards 3 -replicas 3" }, "VolSize" : { "Type": "Number", "Description": "Size in GB of the per machine storage.", "Default": 500 }, "VolType" : { "Type": "String", "Description": "gp2, io1 or standard. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html", "Default": "standard" } }, "Mappings" : { "RegionMap" : { "eu-central-1" : { "AMI" : "ami-00211b1d" }, "ap-northeast-1" : { "AMI" : "ami-24d27b24" }, "us-gov-west-1" : { "AMI" : "ami-eb3a59c8" }, "sa-east-1" : { "AMI" : "ami-47a62a5a" }, "ap-southeast-2" : { "AMI" : "ami-292e6913" }, "ap-southeast-1" : { "AMI" : "ami-0cf1f15e" }, "us-east-1" : { "AMI" : "ami-691cd402" }, "us-west-2" : { "AMI" : "ami-f7a5a5c7" }, "us-west-1" : { "AMI" : "ami-bd8477f9" }, "eu-west-1" : { "AMI" : "ami-52f4b925" } } } }