-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.tf
86 lines (68 loc) · 1.64 KB
/
instance.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
resource "random_integer" "sg" {
min = 0
max = 5000
}
data "template_file" "cloud-init" {
template = "${file("${path.module}/cloud-init.yaml")}"
vars {
template_zip_b64 = "${base64encode(file(local.zipfile))}"
}
depends_on = [
"data.archive_file.init_dir",
]
}
resource "aws_security_group" "allports-exposed" {
name = "allports-exposed-server-sg-${random_integer.sg.result}"
description = "This service does nothing but expose all ports to allow for enumeration"
vpc_id = "${var.vpc_id}"
tags {
Name = "allports-exposed-server-sg-${random_integer.sg.result}"
}
ingress = {
cidr_blocks = [
"0.0.0.0/0",
]
protocol = -1
from_port = 0
to_port = 0
description = "allow all ingress allports-exposed"
}
egress = {
cidr_blocks = [
"0.0.0.0/0",
]
# ALL
protocol = -1
from_port = 0
to_port = 0
description = "allow all outbound"
}
}
resource "aws_instance" "allports-host" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.micro"
user_data = "${data.template_file.cloud-init.rendered}"
vpc_security_group_ids = [
"${aws_security_group.allports-exposed.id}",
]
key_name = "${var.ssh_key_name}"
subnet_id = "${var.subnet_id}"
tags = {
Name = "allports-exposed-host"
}
depends_on = [
"aws_security_group.allports-exposed",
]
lifecycle {
create_before_destroy = true
ignore_changes = [
"user_data",
]
}
}
output "ip-private" {
value = "${aws_instance.allports-host.private_ip}"
}
output "ip-public" {
value = "${aws_instance.allports-host.public_ip}"
}