-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcf-temp-prereq-setup-initial.yaml
288 lines (267 loc) · 10.4 KB
/
cf-temp-prereq-setup-initial.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
AWSTemplateFormatVersion: "2010-09-09"
Description: CloudFormation template to create 3 EC2 instances with Docker, Sysmon, and additional installation.
Parameters:
InstanceType1:
Description: "EC2 Instance type for the first instance"
Type: String
Default: "t2.large"
AllowedValues:
- t2.micro
- t2.small
- t2.medium
- t2.large
- m5.large
- m5.xlarge
ConstraintDescription: "Must be a valid EC2 instance type."
InstanceType2:
Description: "EC2 Instance type for the second instance"
Type: String
Default: "t2.medium"
AllowedValues:
- t2.micro
- t2.small
- t2.medium
- t2.large
- m5.large
- m5.xlarge
ConstraintDescription: "Must be a valid EC2 instance type."
InstanceType3:
Description: "EC2 Instance type for the third instance"
Type: String
Default: "t2.micro"
AllowedValues:
- t2.micro
- t2.small
- t2.medium
- t2.large
- m5.large
- t3.small
ConstraintDescription: "Must be a valid EC2 instance type."
ImageId1:
Description: "AMI ID for the first EC2 instance"
Type: String
ImageId2:
Description: "AMI ID for the second EC2 instance"
Type: String
ImageId3:
Description: "AMI ID for the third EC2 instance"
Type: String
VolumeSize1:
Description: "Volume size for the first EC2 instance in GB"
Type: Number
Default: 300
MinValue: 8
MaxValue: 16384
VolumeSize2:
Description: "Volume size for the second EC2 instance in GB"
Type: Number
Default: 300
MinValue: 8
MaxValue: 16384
VolumeSize3:
Description: "Volume size for the third EC2 instance in GB"
Type: Number
Default: 300
MinValue: 8
MaxValue: 16384
KeyName:
Description: "Name of an existing EC2 KeyPair to enable SSH access to the instances"
Type: AWS::EC2::KeyPair::KeyName
ConstraintDescription: "Must be the name of an existing EC2 KeyPair."
IamInstanceProfile:
Description: "Enter the IAM Instance Profile name to associate with the EC2 instances. Common options: Role1, Role2, Role3, Role4."
Type: String
Default: "ec2roleadmin"
ConstraintDescription: "Must be the name of an existing IAM role."
SecurityGroupId:
Description: "The Security Group ID to associate with the EC2 instances"
Type: AWS::EC2::SecurityGroup::Id
SubnetId:
Description: "The Subnet ID in which to launch the EC2 instances"
Type: AWS::EC2::Subnet::Id
Resources:
ElasticIP1:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
ElasticIP2:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
ELKInstance1:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: !Ref InstanceType1
ImageId: !Ref ImageId1
KeyName: !Ref KeyName
IamInstanceProfile: !Ref IamInstanceProfile
SecurityGroupIds:
- !Ref SecurityGroupId
SubnetId: !Ref SubnetId
BlockDeviceMappings:
- DeviceName: "/dev/sda1"
Ebs:
VolumeSize: !Ref VolumeSize1
VolumeType: gp2
Tags:
- Key: Name
Value: "elk-cribil"
UserData:
Fn::Base64: |
#!/bin/bash
exec > /var/log/user-data.log 2>&1
set -x
sudo apt-get update
sudo apt-get install -y ca-certificates curl unzip apt-transport-https git build-essential gcc make
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf awscliv2.zip aws/
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/11/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y sysmonforlinux
cd /home/ubuntu
git clone https://github.com/saidhfm/Cloud-Threat-Detection-Lab-AWS.git
cd Cloud-Threat-Detection-Lab-AWS
chmod 777 *
cd ELK
chmod 777 *
./elastic-container.sh start
cd ..
docker compose -f cribil.yml up -d
EIPAssociation1:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref ELKInstance1
EIP: !Ref ElasticIP1
ELKInstance2:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: !Ref InstanceType2
ImageId: !Ref ImageId2
KeyName: !Ref KeyName
IamInstanceProfile: !Ref IamInstanceProfile
SecurityGroupIds:
- !Ref SecurityGroupId
SubnetId: !Ref SubnetId
BlockDeviceMappings:
- DeviceName: "/dev/sda1"
Ebs:
VolumeSize: !Ref VolumeSize2
VolumeType: gp2
Tags:
- Key: Name
Value: "splunk"
UserData:
Fn::Base64: |
#!/bin/bash
exec > /var/log/user-data.log 2>&1
set -x
sudo apt-get update
sudo apt-get install -y ca-certificates curl unzip apt-transport-https git build-essential gcc make
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf awscliv2.zip aws/
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/11/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y sysmonforlinux
cd /home/ubuntu
git clone https://github.com/saidhfm/Cloud-Threat-Detection-Lab-AWS.git
cd Cloud-Threat-Detection-Lab-AWS
chmod 777 *
docker compose -f splunk.yml up -d
EIPAssociation2:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref ELKInstance2
EIP: !Ref ElasticIP2
ELKInstance3:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: !Ref InstanceType3
ImageId: !Ref ImageId3
KeyName: !Ref KeyName
IamInstanceProfile: !Ref IamInstanceProfile
SecurityGroupIds:
- !Ref SecurityGroupId
SubnetId: !Ref SubnetId
BlockDeviceMappings:
- DeviceName: "/dev/sda1"
Ebs:
VolumeSize: !Ref VolumeSize3
VolumeType: gp2
Tags:
- Key: Name
Value: "agent"
UserData:
Fn::Base64: |
#!/bin/bash
exec > /var/log/user-data.log 2>&1
set -x
sudo apt-get update
sudo apt-get install -y ca-certificates curl unzip apt-transport-https git build-essential gcc make
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf awscliv2.zip aws/
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/11/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y sysmonforlinux
cd /home/ubuntu
git clone https://github.com/saidhfm/Cloud-Threat-Detection-Lab-AWS.git
Outputs:
InstanceId1:
Description: "Instance ID of the first EC2 instance"
Value: !Ref ELKInstance1
ElasticIP1:
Description: "Elastic IP associated with the first instance"
Value: !Ref ElasticIP1
InstanceId2:
Description: "Instance ID of the second EC2 instance"
Value: !Ref ELKInstance2
ElasticIP2:
Description: "Elastic IP associated with the second instance"
Value: !Ref ElasticIP2
InstanceId3:
Description: "Instance ID of the third EC2 instance"
Value: !Ref ELKInstance3