53 lines
1.5 KiB
Terraform
53 lines
1.5 KiB
Terraform
resource "aws_security_group" "web" {
|
|
region = var.region
|
|
|
|
name = local.ssh_security_group_name
|
|
description = var.ssh_security_group.description
|
|
vpc_id = local.vpc.id
|
|
tags = var.ssh_security_group.tags
|
|
}
|
|
|
|
resource "aws_vpc_security_group_ingress_rule" "web" {
|
|
for_each = var.ssh_ingress_rules
|
|
|
|
region = var.region
|
|
security_group_id = aws_security_group.web.id
|
|
description = each.value.description
|
|
ip_protocol = each.value.ip_protocol
|
|
from_port = each.value.from_port
|
|
to_port = each.value.to_port
|
|
cidr_ipv4 = each.value.cidr_ipv4
|
|
referenced_security_group_id = each.value.use_vyos_security_group ? var.vyos_security_group_id : null
|
|
}
|
|
|
|
resource "aws_vpc_security_group_egress_rule" "web_all_ipv4" {
|
|
region = var.region
|
|
|
|
security_group_id = aws_security_group.web.id
|
|
ip_protocol = "-1"
|
|
cidr_ipv4 = "0.0.0.0/0"
|
|
}
|
|
|
|
# The default SG is adopted. Its two rules are managed as an absolute inline
|
|
# set and must not be mixed with standalone rule resources.
|
|
resource "aws_default_security_group" "this" {
|
|
region = var.region
|
|
vpc_id = local.vpc.id
|
|
|
|
ingress {
|
|
description = null
|
|
protocol = "tcp"
|
|
from_port = 22
|
|
to_port = 22
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
egress {
|
|
description = null
|
|
protocol = "-1"
|
|
from_port = 0
|
|
to_port = 0
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
}
|