-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity_group.tf
More file actions
67 lines (58 loc) · 1.21 KB
/
security_group.tf
File metadata and controls
67 lines (58 loc) · 1.21 KB
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
locals {
ports_in = [
6379,
80,
8080,
443
]
ports_out = [
0
]
}
resource "aws_default_network_acl" "default_network_acl" {
default_network_acl_id = aws_vpc.lambda_vpc.default_network_acl_id
subnet_ids = [aws_subnet.subnet_public.id, ]
ingress {
protocol = -1
rule_no = 100
action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 0
to_port = 0
}
egress {
protocol = -1
rule_no = 100
action = "allow"
cidr_block = "0.0.0.0/0"
from_port = 0
to_port = 0
}
tags = {
Name = "lambda-default-network-acl"
}
}
resource "aws_security_group" "lambda_security_group" {
name = "lambda_security_group"
vpc_id = aws_vpc.lambda_vpc.id
dynamic "ingress" {
for_each = toset(local.ports_in)
content {
description = "open some useful ports"
from_port = ingress.value
to_port = ingress.value
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "lambda-security-group"
}
}