-
Notifications
You must be signed in to change notification settings - Fork 0
/
sg.tf
32 lines (28 loc) · 989 Bytes
/
sg.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
resource "aws_security_group" "minecraft_server" {
name = "minecraft_server"
description = "Allow TCP inbound traffic and all outbound traffic"
vpc_id = "vpc-0af49a5e13633839c"
tags = {
Name = "minecraft_server"
}
}
resource "aws_vpc_security_group_ingress_rule" "minecraft_server_ssh" {
security_group_id = aws_security_group.minecraft_server.id
cidr_ipv4 = local.ssh_source_ip
from_port = 22
ip_protocol = "tcp"
to_port = 22
}
resource "aws_vpc_security_group_ingress_rule" "minecraft_server_port" {
for_each = toset(local.allowed_ips)
security_group_id = aws_security_group.minecraft_server.id
cidr_ipv4 = each.value
from_port = 25565
ip_protocol = "tcp"
to_port = 25565
}
resource "aws_vpc_security_group_egress_rule" "minecraft_server" {
security_group_id = aws_security_group.minecraft_server.id
cidr_ipv4 = "0.0.0.0/0"
ip_protocol = -1
}