-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurity_group.tf
36 lines (29 loc) · 911 Bytes
/
security_group.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
resource "aws_security_group" "this" {
name = var.name
description = var.description
dynamic "ingress" {
for_each = var.ingress
content {
description = ingress.value["description"]
from_port = ingress.value["from_port"]
to_port = ingress.value["to_port"]
protocol = ingress.value["protocol"]
cidr_blocks = ingress.value["cidr_blocks"]
}
}
dynamic "egress" {
for_each = var.egress
content {
description = egress.value["description"]
from_port = egress.value["from_port"]
to_port = egress.value["to_port"]
protocol = egress.value["protocol"]
cidr_blocks = egress.value["cidr_blocks"]
}
}
tags = var.tags
}
resource "aws_network_interface_sg_attachment" "this" {
security_group_id = aws_security_group.this.id
network_interface_id = module.server.primary_network_interface_id
}