{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "Swarm Demonstration Cluster Template", "Parameters" : { "KeyName": { "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances", "Type": "AWS::EC2::KeyPair::KeyName", "Default" : "id_rsa_aws", "ConstraintDescription" : "must be the name of an existing EC2 KeyPair." }, "VpcId" : { "Type" : "AWS::EC2::VPC::Id", "Description" : "ID of the existing VPC into which all machines will be launched" }, "SubnetId" : { "Type" : "AWS::EC2::Subnet::Id", "Description" : "ID of an existing subnet into which all machines will be launched" }, "managerIP" : { "Description" : "IP of manager (where Swarm Manager and consul kv run)", "Type": "String", "MinLength": "7", "MaxLength": "15", "Default": "192.168.33.11", "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "ConstraintDescription": "must be a valid IP of the form x.x.x.x" }, "interlockIP" : { "Description" : "IP of interlock (load balancer for web-vote-app)", "Type": "String", "MinLength": "7", "MaxLength": "15", "Default": "192.168.33.12", "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "ConstraintDescription": "must be a valid IP of the form x.x.x.x" }, "frontend01IP" : { "Description" : "IP of frontend01", "Type": "String", "MinLength": "7", "MaxLength": "15", "Default": "192.168.33.20", "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "ConstraintDescription": "must be a valid IP of the form x.x.x.x" }, "frontend02IP" : { "Description" : "IP of frontend02", "Type": "String", "MinLength": "7", "MaxLength": "15", "Default": "192.168.33.21", "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "ConstraintDescription": "must be a valid IP of the form x.x.x.x" }, "worker01IP" : { "Description" : "IP of worker01", "Type": "String", "MinLength": "7", "MaxLength": "15", "Default": "192.168.33.200", "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "ConstraintDescription": "must be a valid IP of the form x.x.x.x" }, "storeIP" : { "Description" : "IP of store", "Type": "String", "MinLength": "7", "MaxLength": "15", "Default": "192.168.33.250", "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})", "ConstraintDescription": "must be a valid IP of the form x.x.x.x" } }, "Mappings" : { "AWSInstanceType2Arch" : { "t2.micro" : { "Arch" : "HVM64" }, "t2.small" : { "Arch" : "HVM64" }, "t2.medium" : { "Arch" : "HVM64" }, "t2.large" : { "Arch" : "HVM64" }, "m3.medium" : { "Arch" : "HVM64" }, "m3.large" : { "Arch" : "HVM64" }, "m3.xlarge" : { "Arch" : "HVM64" }, "m3.2xlarge" : { "Arch" : "HVM64" }, "c3.large" : { "Arch" : "HVM64" }, "c3.xlarge" : { "Arch" : "HVM64" }, "c3.2xlarge" : { "Arch" : "HVM64" }, "c3.4xlarge" : { "Arch" : "HVM64" }, "c3.8xlarge" : { "Arch" : "HVM64" }, "c4.large" : { "Arch" : "HVM64" }, "c4.xlarge" : { "Arch" : "HVM64" }, "c4.2xlarge" : { "Arch" : "HVM64" }, "c4.4xlarge" : { "Arch" : "HVM64" }, "c4.8xlarge" : { "Arch" : "HVM64" }, "g2.2xlarge" : { "Arch" : "HVMG2" }, "r3.large" : { "Arch" : "HVM64" }, "r3.xlarge" : { "Arch" : "HVM64" }, "r3.2xlarge" : { "Arch" : "HVM64" }, "r3.4xlarge" : { "Arch" : "HVM64" }, "r3.8xlarge" : { "Arch" : "HVM64" }, "i2.xlarge" : { "Arch" : "HVM64" }, "i2.2xlarge" : { "Arch" : "HVM64" }, "i2.4xlarge" : { "Arch" : "HVM64" }, "i2.8xlarge" : { "Arch" : "HVM64" }, "d2.xlarge" : { "Arch" : "HVM64" }, "d2.2xlarge" : { "Arch" : "HVM64" }, "d2.4xlarge" : { "Arch" : "HVM64" }, "d2.8xlarge" : { "Arch" : "HVM64" }, "hi1.4xlarge" : { "Arch" : "HVM64" }, "hs1.8xlarge" : { "Arch" : "HVM64" }, "cr1.8xlarge" : { "Arch" : "HVM64" }, "cc2.8xlarge" : { "Arch" : "HVM64" } }, "AWSRegionArch2AMI" : { "us-east-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "us-west-2" : {"HVM64" : "ami-aff71acf", "HVMG2" : "ami-aff71acf"}, "us-west-1" : {"HVM64" : "ami-d05b2bb0", "HVMG2" : "ami-d05b2bb0"}, "eu-west-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "eu-central-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "ap-northeast-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "ap-southeast-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "ap-southeast-2" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "sa-east-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"}, "cn-north-1" : {"HVM64" : "NOT_SUPPORTED", "HVMG2" : "NOT_SUPPORTED"} } }, "Resources" : { "manager" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceType" : "t2.micro", "SecurityGroupIds" : [ { "Ref" : "WideOpenVpcSG" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", "t2.micro", "Arch" ] } ] }, "SubnetId" : { "Ref" : "SubnetId" }, "PrivateIpAddress" : { "Ref" : "managerIP" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "\n", [ "#!/bin/bash", "sudo hostname manager", "sudo service docker stop", "sudo rm -f /etc/docker/key.json", "sudo service docker start" ] ] } }, "Tags" : [ {"Key" : "Name", "Value" : "manager"} ] } }, "interlock" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceType" : "t2.micro", "SecurityGroupIds" : [ { "Ref" : "WideOpenVpcSG" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", "t2.micro", "Arch" ] } ] }, "SubnetId" : { "Ref" : "SubnetId" }, "PrivateIpAddress" : { "Ref" : "interlockIP" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "\n", [ "#!/bin/bash", "sudo hostname interlock", "sudo service docker stop", "sudo rm -f /etc/docker/key.json", "sudo service docker start" ] ] } }, "Tags" : [ {"Key" : "Name", "Value" : "interlock"} ] } }, "frontend01" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceType" : "t2.micro", "SecurityGroupIds" : [ { "Ref" : "WideOpenVpcSG" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", "t2.micro", "Arch" ] } ] }, "SubnetId" : { "Ref" : "SubnetId" }, "PrivateIpAddress" : { "Ref" : "frontend01IP" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "\n", [ "#!/bin/bash", "sudo hostname frontend01", "sudo service docker stop", "sudo rm -f /etc/docker/key.json", "sudo service docker start" ] ] } }, "Tags" : [ {"Key" : "Name", "Value" : "frontend01"} ] } }, "frontend02" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceType" : "t2.micro", "SecurityGroupIds" : [ { "Ref" : "WideOpenVpcSG" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", "t2.micro", "Arch" ] } ] }, "SubnetId" : { "Ref" : "SubnetId" }, "PrivateIpAddress" : { "Ref" : "frontend02IP" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "\n", [ "#!/bin/bash", "sudo hostname frontend02", "sudo service docker stop", "sudo rm -f /etc/docker/key.json", "sudo service docker start" ] ] } }, "Tags" : [ {"Key" : "Name", "Value" : "frontend02"} ] } }, "worker01" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceType" : "t2.micro", "SecurityGroupIds" : [ { "Ref" : "WideOpenVpcSG" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", "t2.micro", "Arch" ] } ] }, "SubnetId" : { "Ref" : "SubnetId" }, "PrivateIpAddress" : { "Ref" : "worker01IP" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "\n", [ "#!/bin/bash", "sudo hostname worker01", "sudo service docker stop", "sudo rm -f /etc/docker/key.json", "sudo service docker start" ] ] } }, "Tags" : [ {"Key" : "Name", "Value" : "worker01"} ] } }, "store" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceType" : "m3.medium", "SecurityGroupIds" : [ { "Ref" : "WideOpenVpcSG" } ], "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", "m3.medium", "Arch" ] } ] }, "SubnetId" : { "Ref" : "SubnetId" }, "PrivateIpAddress" : { "Ref" : "storeIP" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "\n", [ "#!/bin/bash", "sudo hostname store", "sudo service docker stop", "sudo rm -f /etc/docker/key.json", "sudo service docker start" ] ] } }, "Tags" : [ {"Key" : "Name", "Value" : "store"} ] } }, "WideOpenVpcSG" : { "Type" : "AWS::EC2::SecurityGroup", "Properties" : { "VpcId" : { "Ref" : "VpcId" } , "GroupDescription" : "Wide open", "SecurityGroupIngress" : [ { "IpProtocol" : "-1", "FromPort" : "0", "ToPort" : "65535", "CidrIp" : "0.0.0.0/0" } ] } } }, "Outputs" : { "managerPrivateIP" : { "Description" : "Private IP of manager", "Value" : { "Fn::GetAtt" : [ "manager", "PrivateIp" ] } }, "managerPublicIP" : { "Description" : "Public IP of manager", "Value" : { "Fn::GetAtt" : [ "manager", "PublicIp" ] } }, "interlockPrivateIP" : { "Description" : "Private IP of interlock", "Value" : { "Fn::GetAtt" : [ "interlock", "PrivateIp" ] } }, "interlockPublicIP" : { "Description" : "Public IP of interlock", "Value" : { "Fn::GetAtt" : [ "interlock", "PublicIp" ] } }, "frontend01PrivateIP" : { "Description" : "Private IP of frontend01", "Value" : { "Fn::GetAtt" : [ "frontend01", "PrivateIp" ] } }, "frontend01PublicIP" : { "Description" : "Public IP of frontend01", "Value" : { "Fn::GetAtt" : [ "frontend01", "PublicIp" ] } }, "frontend02PrivateIP" : { "Description" : "Private IP of frontend02", "Value" : { "Fn::GetAtt" : [ "frontend02", "PrivateIp" ] } }, "frontend02PublicIP" : { "Description" : "Public IP of frontend02", "Value" : { "Fn::GetAtt" : [ "frontend02", "PublicIp" ] } }, "worker01PrivateIP" : { "Description" : "Private IP of worker01", "Value" : { "Fn::GetAtt" : [ "worker01", "PrivateIp" ] } }, "worker01PublicIP" : { "Description" : "Public IP of worker01", "Value" : { "Fn::GetAtt" : [ "worker01", "PublicIp" ] } }, "storePrivateIP" : { "Description" : "Private IP of store", "Value" : { "Fn::GetAtt" : [ "store", "PrivateIp" ] } }, "storePublicIP" : { "Description" : "Public IP of store", "Value" : { "Fn::GetAtt" : [ "store", "PublicIp" ] } } } }