This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloudformation.json
162 lines (141 loc) · 6 KB
/
cloudformation.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Build an AWS VPC with a single public subnet in a single AZ.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores."
}
},
"Mappings" : {
"NatRegionMap" : {
"us-east-1" : { "AMI" : "ami-184dc970" },
"us-west-1" : { "AMI" : "ami-a98396ec" },
"us-west-2" : { "AMI" : "ami-290f4119" },
"eu-west-1" : { "AMI" : "ami-14913f63" },
"eu-central-1" : { "AMI" : "ami-ae380eb3" },
"sa-east-1" : { "AMI" : "ami-8122969c" },
"ap-southeast-1" : { "AMI" : "ami-6aa38238" },
"ap-southeast-2" : { "AMI" : "ami-893f53b3" },
"ap-northeast-1" : { "AMI" : "ami-27d6e626" }
}
},
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "192.168.0.0/16",
"EnableDnsSupport" : true,
"EnableDnsHostnames" : true,
"Tags" : [
{"Key" : "Name", "Value" : { "Ref" : "AWS::StackName"} },
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} },
{"Key" : "Network", "Value" : "Public" }
]
}
},
"secg": {
"Type": "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Insecure Group All Traffic",
"VpcId" : { "Ref" : "VPC" },
"SecurityGroupIngress": [
{"IpProtocol": "-1", "FromPort": "0", "ToPort": "65535", "CidrIp": "0.0.0.0/0"}
],
"SecurityGroupEgress": [
{"IpProtocol": "-1", "FromPort": "0", "ToPort": "65535", "CidrIp": "0.0.0.0/0"}
]
}
},
"PublicSubnet" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"CidrBlock" : "192.168.1.0/24",
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} },
{"Key" : "Network", "Value" : "Public" }
]
}
},
"NAT" : {
"DependsOn" : ["PublicSubnet", "secg"],
"Type" : "AWS::EC2::Instance",
"Properties" : {
"InstanceType" : "t2.micro",
"KeyName" : { "Ref" : "KeyName" },
"SourceDestCheck" : "false",
"ImageId" : { "Fn::FindInMap" : [ "NatRegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"NetworkInterfaces" : [{
"GroupSet" : [{ "Ref" : "secg" }],
"AssociatePublicIpAddress" : "true",
"DeviceIndex" : "0",
"DeleteOnTermination" : "true",
"SubnetId" : { "Ref" : "PublicSubnet" }
}],
"Tags" : [
{ "Key" : "Name", "Value" : "NAT" }
],
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"yum update -y && yum install -y yum-cron && chkconfig yum-cron on"
]]}}
}
},
"InternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} },
{"Key" : "Network", "Value" : "Public" }
]
}
},
"AttachGateway" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"InternetGatewayId" : { "Ref" : "InternetGateway" }
}
},
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : {"Ref" : "VPC"},
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} },
{"Key" : "Network", "Value" : "Public" }
]
}
},
"PublicRoute" : {
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "PublicRouteTable" },
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : { "Ref" : "InternetGateway" }
}
},
"PublicSubnetRouteTableAssociation" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PublicSubnet" },
"RouteTableId" : { "Ref" : "PublicRouteTable" }
}
}
},
"Outputs" : {
"VpcID" : {
"Value" : {"Ref" : "VPC"},
"Description" : "VPC ID of newly created VPC"
},
"PublicSubnetID" : {
"Value" : {"Ref" : "PublicSubnet"},
"Description" : "Public subnet ID"
}
}
}