Skip to content

Instantly share code, notes, and snippets.

@namtx
Created October 3, 2018 07:45
Show Gist options
  • Select an option

  • Save namtx/ee1e33613db9b27c3418c5e4ba09e41c to your computer and use it in GitHub Desktop.

Select an option

Save namtx/ee1e33613db9b27c3418c5e4ba09e41c to your computer and use it in GitHub Desktop.
CloudFormation Lab
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
"AWS::CloudFormation::Designer": {
"7b463913-5e19-4c74-898a-2220105ccd41": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 310,
"y": 300
},
"z": 0,
"embeds": []
},
"1a126032-3cd8-48be-bfb7-ef7194541d7f": {
"size": {
"width": 670,
"height": 280
},
"position": {
"x": 500,
"y": 130
},
"z": 0,
"embeds": [
"99ca1073-3c47-42b8-948d-8daeb5d7707e",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9"
]
},
"9be44238-e38f-48e7-8235-0083a0eb5540": {
"size": {
"width": 140,
"height": 140
},
"position": {
"x": 900,
"y": 150
},
"z": 1,
"parent": "1a126032-3cd8-48be-bfb7-ef7194541d7f",
"embeds": [
"7de57362-4240-4a7f-b898-3d08cdc8e893"
],
"iscontainedinside": [
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f"
]
},
"7de57362-4240-4a7f-b898-3d08cdc8e893": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 919,
"y": 200
},
"z": 2,
"parent": "9be44238-e38f-48e7-8235-0083a0eb5540",
"embeds": [],
"iscontainedinside": [
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540",
"9be44238-e38f-48e7-8235-0083a0eb5540"
],
"dependson": [
"12f99438-6e4b-405f-9d61-f97b0033a2fa"
]
},
"d57ff2a2-d561-4981-b839-c86f25cf1ee9": {
"size": {
"width": 140,
"height": 140
},
"position": {
"x": 600,
"y": 150
},
"z": 1,
"parent": "1a126032-3cd8-48be-bfb7-ef7194541d7f",
"embeds": [
"12f99438-6e4b-405f-9d61-f97b0033a2fa"
],
"iscontainedinside": [
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f"
],
"dependson": [
"9be44238-e38f-48e7-8235-0083a0eb5540"
]
},
"12f99438-6e4b-405f-9d61-f97b0033a2fa": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 626,
"y": 189
},
"z": 2,
"parent": "d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"embeds": [],
"iscontainedinside": [
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9",
"d57ff2a2-d561-4981-b839-c86f25cf1ee9"
],
"dependson": [
"7b463913-5e19-4c74-898a-2220105ccd41"
]
},
"971ad957-61d0-41d9-9168-b4ca801d7d9b": {
"source": {
"id": "1a126032-3cd8-48be-bfb7-ef7194541d7f"
},
"target": {
"id": "7b463913-5e19-4c74-898a-2220105ccd41"
},
"z": 0
},
"99ca1073-3c47-42b8-948d-8daeb5d7707e": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 750,
"y": 310
},
"z": 1,
"parent": "1a126032-3cd8-48be-bfb7-ef7194541d7f",
"embeds": [],
"iscontainedinside": [
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f",
"1a126032-3cd8-48be-bfb7-ef7194541d7f"
]
}
}
},
"Parameters": {
"InstanceType": {
"Description": "WebServer EC2 instance type",
"Type": "String",
"Default": "t2.micro",
"AllowedValues": [
"t1.micro",
"t2.micro",
"t2.small",
"t2.medium",
"m1.small",
"m1.medium",
"m1.large",
"m1.xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"m3.medium",
"m3.large",
"m3.xlarge",
"m3.2xlarge",
"c1.medium",
"c1.xlarge",
"c3.large",
"c3.xlarge",
"c3.2xlarge",
"c3.4xlarge",
"c3.8xlarge",
"c4.large",
"c4.xlarge",
"c4.2xlarge",
"c4.4xlarge",
"c4.8xlarge",
"g2.2xlarge",
"r3.large",
"r3.xlarge",
"r3.2xlarge",
"r3.4xlarge",
"r3.8xlarge",
"i2.xlarge",
"i2.2xlarge",
"i2.4xlarge",
"i2.8xlarge",
"d2.xlarge",
"d2.2xlarge",
"d2.4xlarge",
"d2.8xlarge",
"hi1.4xlarge",
"hs1.8xlarge",
"cr1.8xlarge",
"cc2.8xlarge",
"cg1.4xlarge"
],
"ConstraintDescription": "must be a valid EC2 instance type."
},
"KeyName": {
"Description": "Name of EC2 KeyPair to enable SSH access to the instance.",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription": "must be then name of an existing EC2 KeyPair."
},
"SSHLocation": {
"Description": "The IP address range that can be sed to access the web server usign SSH",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
}
},
"Mappings": {
"AWSInstanceType2Arch": {
"t1.micro": {
"Arch": "PV64"
},
"t2.micro": {
"Arch": "HVM64"
},
"t2.small": {
"Arch": "HVM64"
},
"t2.medium": {
"Arch": "HVM64"
},
"m1.small": {
"Arch": "PV64"
},
"m1.medium": {
"Arch": "PV64"
},
"m1.large": {
"Arch": "PV64"
},
"m1.xlarge": {
"Arch": "PV64"
},
"m2.xlarge": {
"Arch": "PV64"
},
"m2.2xlarge": {
"Arch": "PV64"
},
"m2.4xlarge": {
"Arch": "PV64"
},
"m3.medium": {
"Arch": "HVM64"
},
"m3.large": {
"Arch": "HVM64"
},
"m3.xlarge": {
"Arch": "HVM64"
},
"m3.2xlarge": {
"Arch": "HVM64"
},
"c1.medium": {
"Arch": "PV64"
},
"c1.xlarge": {
"Arch": "PV64"
},
"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": {
"PV64": "ami-1ccae774",
"HVM64": "ami-1ecae776",
"HVMG2": "ami-8c6b40e4"
},
"us-west-2": {
"PV64": "ami-ff527ecf",
"HVM64": "ami-e7527ed7",
"HVMG2": "ami-abbe919b"
},
"us-west-1": {
"PV64": "ami-d514f291",
"HVM64": "ami-d114f295",
"HVMG2": "ami-f31ffeb7"
},
"eu-west-1": {
"PV64": "ami-bf0897c8",
"HVM64": "ami-a10897d6",
"HVMG2": "ami-d5bc24a2"
},
"eu-central-1": {
"PV64": "ami-ac221fb1",
"HVM64": "ami-a8221fb5",
"HVMG2": "ami-7cd2ef61"
},
"ap-northeast-1": {
"PV64": "ami-27f90e27",
"HVM64": "ami-cbf90ecb",
"HVMG2": "ami-6318e863"
},
"ap-southeast-1": {
"PV64": "ami-acd9e8fe",
"HVM64": "ami-68d8e93a",
"HVMG2": "ami-3807376a"
},
"ap-southeast-2": {
"PV64": "ami-ff9cecc5",
"HVM64": "ami-fd9cecc7",
"HVMG2": "ami-89790ab3"
},
"sa-east-1": {
"PV64": "ami-bb2890a6",
"HVM64": "ami-b52890a8",
"HVMG2": "NOT_SUPPORTED"
},
"cn-north-1": {
"PV64": "ami-fa39abc3",
"HVM64": "ami-f239abcb",
"HVMG2": "NOT_SUPPORTED"
}
}
},
"Resources": {
"IGW": {
"Type": "AWS::EC2::InternetGateway",
"Properties": {
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "7b463913-5e19-4c74-898a-2220105ccd41"
}
}
},
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"CidrBlock": "10.0.0.0/16"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "1a126032-3cd8-48be-bfb7-ef7194541d7f"
}
}
},
"PubSub": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"CidrBlock": "10.0.0.0/24"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "9be44238-e38f-48e7-8235-0083a0eb5540"
}
}
},
"WebServer": {
"Type": "AWS::EC2::Instance",
"Properties": {
"InstanceType": {
"Ref": "InstanceType"
},
"ImageId": {
"Fn::FindInMap": [
"AWSRegionArch2AMI",
{
"Ref": "AWS::Region"
},
{
"Fn::FindInMap": [
"AWSInstanceType2Arch",
{
"Ref": "InstanceType"
},
"Arch"
]
}
]
},
"KeyName": {
"Ref": "KeyName"
},
"NetworkInterfaces": [
{
"GroupSet": [{"Ref": "SecurityGroup"}],
"AssociatedPublicIpAddress": "true",
"DeviceIndex": "0",
"DeleteOnTermination": "true",
"SubnetId": {
"Ref": "PubSub"
}
}
]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "7de57362-4240-4a7f-b898-3d08cdc8e893",
"AWS::CloudFormation::Init": {
"configSets": {
"All": [
"ConfigureSampleApp"
]
},
"ConfigureSampleApp": {
"packages": {
"yum": {
"httpd": []
}
},
"files": {
"/var/www/html/index.html": {
"content": {
"Fn::Join": [
"\n",
[
"<h1>Congratulations, you have successfully launched the AWS CloudFormation sample.</h1>"
]
]
},
"mode": "000644",
"owner": "root",
"group": "root"
}
},
"services": {
"sysvinit": {
"httpd": {
"enabled": "true",
"ensureRunning": "true"
}
}
}
}
}
}
},
"DependsOn": [
"PubRoute"
]
},
"PubRouteTable": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "VPC"
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "d57ff2a2-d561-4981-b839-c86f25cf1ee9"
}
},
"DependsOn": [
"PubSub"
]
},
"PubRoute": {
"Type": "AWS::EC2::Route",
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
"Ref": "PubRouteTable"
},
"GatewayId": {
"Ref": "IGW"
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "12f99438-6e4b-405f-9d61-f97b0033a2fa"
}
},
"DependsOn": [
"IGW"
]
},
"EC2VPCG57DBU": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"InternetGatewayId": {
"Ref": "IGW"
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "971ad957-61d0-41d9-9168-b4ca801d7d9b"
}
}
},
"SecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"GroupDescription": "Allow access from HTTP and SSH traffic",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": {
"Ref": "SSHLocation"
}
}
]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "99ca1073-3c47-42b8-948d-8daeb5d7707e"
}
}
}
},
"Outputs": {
"URL": {
"Value": {
"Fn::Join": [
"",
[
"http://",
{
"Fn::GetAtt": [
"WebServer",
"PublicIp"
]
}
]
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment