2022-02-15 18:00:24 +00:00
|
|
|
# Security group for the backends that run the application.
|
|
|
|
# Allows traffic from the load balancer
|
|
|
|
resource "aws_security_group" "backend" {
|
|
|
|
name = "${local.prefix} backend"
|
|
|
|
description = "${local.prefix} Backend security group"
|
2022-05-03 14:51:11 +00:00
|
|
|
vpc_id = data.terraform_remote_state.shared.outputs.vpc.vpc_id
|
2022-02-15 18:00:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Allow traffic from the load balancer to the backends
|
|
|
|
resource "aws_security_group_rule" "backend-ingress" {
|
|
|
|
description = "${local.prefix}: allow traffic from load balancer"
|
|
|
|
type = "ingress"
|
|
|
|
|
|
|
|
from_port = "8080"
|
|
|
|
to_port = "8080"
|
|
|
|
protocol = "tcp"
|
2022-05-03 14:51:11 +00:00
|
|
|
source_security_group_id = data.terraform_remote_state.shared.outputs.alb_security_group.id
|
2022-02-15 18:00:24 +00:00
|
|
|
security_group_id = aws_security_group.backend.id
|
|
|
|
}
|
|
|
|
|
|
|
|
# Allow outbound traffic from the backends
|
|
|
|
resource "aws_security_group_rule" "backend-egress" {
|
|
|
|
description = "${local.prefix}: allow all outbound traffic"
|
|
|
|
type = "egress"
|
|
|
|
|
2022-03-31 16:36:18 +00:00
|
|
|
from_port = 0
|
|
|
|
to_port = 0
|
|
|
|
protocol = "-1"
|
|
|
|
cidr_blocks = ["0.0.0.0/0"] #tfsec:ignore:aws-vpc-no-public-egress-sgr
|
2022-02-15 18:00:24 +00:00
|
|
|
|
|
|
|
security_group_id = aws_security_group.backend.id
|
|
|
|
}
|