-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstances.tf
67 lines (50 loc) · 1.49 KB
/
instances.tf
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
###################### Good Guy Instance ###########################
resource "aws_instance" "good" {
ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type
subnet_id = aws_subnet.subnet.id
vpc_security_group_ids = [aws_security_group.lab-sg.id]
private_ip = "10.0.0.100"
key_name = "lab-key"
user_data = <<EOF
#! /bin/bash
sudo apt-get update -y
sudo apt install nmap -y
sudo apt-get install nginx -y
sudo apt-get install vsftpd -y
EOF
tags = {
Name = "good"
}
}
############################ Bad Guy instance ############################
resource "aws_instance" "bad" {
ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type
subnet_id = aws_subnet.subnet.id
vpc_security_group_ids = [aws_security_group.lab-sg.id]
private_ip = "10.0.0.200"
key_name = "lab-key"
user_data = <<EOF
#! /bin/bash
sudo apt-get update -y
sudo apt install nmap -y
sudo apt install net-tools -y
EOF
tags = {
Name = "bad"
}
}
#### SSH Keys and PEM File ########
resource "aws_key_pair" "deployer" {
key_name = "lab-key"
public_key = tls_private_key.rsa.public_key_openssh
}
resource "tls_private_key" "rsa" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "local_file" "test-key" {
content = tls_private_key.rsa.private_key_pem
filename = "test-key"
}