Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions infrastructure/modules/security/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 55 additions & 55 deletions infrastructure/modules/security/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,61 +25,6 @@ resource "aws_security_group" "alb" {
}
}

resource "aws_security_group" "ecs" {
description = "Security group for ECS tasks"
name = "${var.project_name}-${var.environment}-ecs-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-ecs-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group" "frontend" {
description = "Security group for frontend ECS tasks"
name = "${var.project_name}-${var.environment}-frontend-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-frontend-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group" "lambda" {
description = "Security group for Lambda functions (Zappa)"
name = "${var.project_name}-${var.environment}-lambda-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-lambda-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group" "rds" {
description = "Security group for RDS PostgreSQL"
name = "${var.project_name}-${var.environment}-rds-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-rds-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group" "rds_proxy" {
count = var.create_rds_proxy ? 1 : 0
description = "Security group for RDS Proxy"
name = "${var.project_name}-${var.environment}-rds-proxy-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-rds-proxy-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group" "redis" {
description = "Security group for ElastiCache Redis"
name = "${var.project_name}-${var.environment}-redis-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-redis-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "alb_http" {
cidr_blocks = ["0.0.0.0/0"]
description = "Allow HTTP from internet"
Expand Down Expand Up @@ -110,6 +55,15 @@ resource "aws_security_group_rule" "alb_to_frontend" {
type = "egress"
}

resource "aws_security_group" "ecs" {
description = "Security group for ECS tasks"
name = "${var.project_name}-${var.environment}-ecs-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-ecs-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "ecs_egress_all" {
cidr_blocks = var.default_egress_cidr_blocks
description = "Allow all outbound traffic"
Expand All @@ -131,6 +85,15 @@ resource "aws_security_group_rule" "ecs_to_vpc_endpoints" {
type = "egress"
}

resource "aws_security_group" "frontend" {
description = "Security group for frontend ECS tasks"
name = "${var.project_name}-${var.environment}-frontend-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-frontend-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "frontend_from_alb" {
description = "Allow traffic from ALB"
from_port = 3000
Expand Down Expand Up @@ -162,6 +125,15 @@ resource "aws_security_group_rule" "frontend_to_vpc_endpoints" {
type = "egress"
}

resource "aws_security_group" "lambda" {
description = "Security group for Lambda functions (Zappa)"
name = "${var.project_name}-${var.environment}-lambda-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-lambda-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "lambda_egress_all" {
cidr_blocks = var.default_egress_cidr_blocks
description = "Allow all outbound traffic"
Expand All @@ -183,6 +155,25 @@ resource "aws_security_group_rule" "lambda_to_vpc_endpoints" {
type = "egress"
}

resource "aws_security_group" "rds" {
description = "Security group for RDS PostgreSQL"
name = "${var.project_name}-${var.environment}-rds-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-rds-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group" "rds_proxy" {
count = var.create_rds_proxy ? 1 : 0
description = "Security group for RDS Proxy"
name = "${var.project_name}-${var.environment}-rds-proxy-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-rds-proxy-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "rds_from_ecs" {
count = var.create_rds_proxy ? 0 : 1
description = "PostgreSQL from ECS"
Expand Down Expand Up @@ -249,6 +240,15 @@ resource "aws_security_group_rule" "rds_proxy_from_lambda" {
type = "ingress"
}

resource "aws_security_group" "redis" {
description = "Security group for ElastiCache Redis"
name = "${var.project_name}-${var.environment}-redis-sg"
tags = merge(var.common_tags, {
Name = "${var.project_name}-${var.environment}-redis-sg"
})
vpc_id = var.vpc_id
}

resource "aws_security_group_rule" "redis_from_ecs" {
description = "Redis from ECS"
from_port = var.redis_port
Expand Down
Loading
Loading