-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstances.yaml
321 lines (306 loc) · 6.9 KB
/
instances.yaml
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Test instances.
Parameters:
VPCStackName:
Type: String
Description: The name of the VPC Stack.
InstanceType:
Type: String
Description: The AWS instance type.
AllowedValues:
- t2.micro
- t2.small
- t2.medium
- t2.large
- m4.large
- t2.xlarge
- t2.2xlarge
- m4.xlarge
- m4.2xlarge
- m4.4xlarge
Default: t2.medium
KeyName:
Type: AWS::EC2::KeyPair::KeyName
Description: The key that will be used to SSH into the instance.
LaunchPublic1:
Type: String
Description: Yes, to launch an instance in the first public subnet.
AllowedValues:
- 'Yes'
- 'No'
Default: 'Yes'
LaunchPublic2:
Type: String
Description: Yes, to launch an instance in the second public subnet.
AllowedValues:
- 'Yes'
- 'No'
Default: 'No'
LaunchPublic3:
Type: String
Description: Yes, to launch an instance in the third public subnet.
AllowedValues:
- 'Yes'
- 'No'
Default: 'No'
LaunchPrivate1:
Type: String
Description: Yes, to launch an instance in the first private subnet.
AllowedValues:
- 'Yes'
- 'No'
Default: 'No'
LaunchPrivate2:
Type: String
Description: Yes, to launch an instance in the second private subnet.
AllowedValues:
- 'Yes'
- 'No'
Default: 'No'
LaunchPrivate3:
Type: String
Description: Yes, to launch an instance in the third private subnet.
AllowedValues:
- 'Yes'
- 'No'
Default: 'No'
# Metadata
Metadata:
AWS::CloudFormation::Interface:
# Parameter Groups
ParameterGroups:
- Label:
default: VPC & Instance Information
Parameters:
- VPCStackName
- InstanceType
- KeyName
- Label:
default: Launch Zones
Parameters:
- LaunchPublic1
- LaunchPublic2
- LaunchPublic3
- LaunchPrivate1
- LaunchPrivate2
- LaunchPrivate3
# Parameter Labels
ParameterLabels:
VPCStackName:
default: VPC Stack
LaunchPublic1:
default: Public Subnet 1
LaunchPublic1:
default: Public Subnet 2
LaunchPublic3:
default: Public Subnet 3
LaunchPrivate1:
default: Private Subnet 1
LaunchPrivate2:
default: Private Subnet 2
LaunchPrivate3:
default: Private Subnet 3
# Conditions
Conditions:
Public1: !Equals [ 'Yes', !Ref LaunchPublic1 ]
Public2: !Equals [ 'Yes', !Ref LaunchPublic2 ]
Public3: !Equals [ 'Yes', !Ref LaunchPublic3 ]
Private1: !Equals [ 'Yes', !Ref LaunchPrivate1 ]
Private2: !Equals [ 'Yes', !Ref LaunchPrivate2 ]
Private3: !Equals [ 'Yes', !Ref LaunchPrivate3 ]
# Mappings
Mappings:
RegionMap:
us-east-1:
AMI: ami-4fffc834
# Resources
Resources:
# Security Group.
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: test-instance
GroupDescription: test-instance
VpcId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:vpc
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: test-instance
# Public 1 Instance
Public1Instance:
Type: AWS::EC2::Instance
Condition: Public1
Properties:
InstanceType:
Ref: InstanceType
ImageId:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- AMI
KeyName:
Ref: KeyName
SecurityGroupIds:
- Ref: SecurityGroup
SubnetId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:public-subnet-1
Tags:
- Key: Name
Value: test-instance
# Public 2 Instance
Public2Instance:
Type: AWS::EC2::Instance
Condition: Public2
Properties:
InstanceType:
Ref: InstanceType
ImageId:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- AMI
KeyName:
Ref: KeyName
SecurityGroupIds:
- Ref: SecurityGroup
SubnetId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:public-subnet-2
Tags:
- Key: Name
Value: test-instance
# Public 3 Instance
Public3Instance:
Type: AWS::EC2::Instance
Condition: Public3
Properties:
InstanceType:
Ref: InstanceType
ImageId:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- AMI
KeyName:
Ref: KeyName
SecurityGroupIds:
- Ref: SecurityGroup
SubnetId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:public-subnet-3
Tags:
- Key: Name
Value: test-instance
# Private 1 Instance
Private1Instance:
Type: AWS::EC2::Instance
Condition: Private1
Properties:
InstanceType:
Ref: InstanceType
ImageId:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- AMI
KeyName:
Ref: KeyName
SecurityGroupIds:
- Ref: SecurityGroup
SubnetId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:private-subnet-1
Tags:
- Key: Name
Value: test-instance
# Private 2 Instance
Private2Instance:
Type: AWS::EC2::Instance
Condition: Private2
Properties:
InstanceType:
Ref: InstanceType
ImageId:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- AMI
KeyName:
Ref: KeyName
SecurityGroupIds:
- Ref: SecurityGroup
SubnetId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:private-subnet-2
Tags:
- Key: Name
Value: test-instance
# Private 3 Instance
Private3Instance:
Type: AWS::EC2::Instance
Condition: Private3
Properties:
InstanceType:
Ref: InstanceType
ImageId:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- AMI
KeyName:
Ref: KeyName
SecurityGroupIds:
- Ref: SecurityGroup
SubnetId:
Fn::ImportValue:
Fn::Sub:
${VPCStackName}:private-subnet-3
Tags:
- Key: Name
Value: test-instance
# Outputs:
Outputs:
Public1Instance:
Value:
Ref: Public1Instance
Export:
Name: !Sub ${AWS::StackName}-public-1-instance
Public2Instance:
Value:
Ref: Public2Instance
Export:
Name: !Sub ${AWS::StackName}-public-2-instance
Public3Instance:
Value:
Ref: Public3Instance
Export:
Name: !Sub ${AWS::StackName}-public-3-instance
Private1Instance:
Value:
Ref: Private1Instance
Export:
Name: !Sub ${AWS::StackName}-private-1-instance
Private2Instance:
Value:
Ref: Private2Instance
Export:
Name: !Sub ${AWS::StackName}-private-2-instance
Private3Instance:
Value:
Ref: Private3Instance
Export:
Name: !Sub ${AWS::StackName}-private-3-instance