# Create a security group for the ALB. resource "aws_security_group" "ecs_sg" { name = var.ecs_sg_name description = "ECS security group for the ALB." vpc_id = var.vpc ingress { protocol = "tcp" from_port = 80 to_port = 80 cidr_blocks = ["0.0.0.0/0"] } ingress { protocol = "tcp" from_port = 8080 to_port = 8080 cidr_blocks = ["0.0.0.0/0"] } ingress { protocol = "tcp" from_port = 443 to_port = 443 cidr_blocks = ["0.0.0.0/0"] } ingress { protocol = "tcp" from_port = 31000 to_port = 61000 self = true } egress { protocol = "-1" from_port = 0 to_port = 0 cidr_blocks = ["0.0.0.0/0"] } } # Create a CloudWatch log group. resource "aws_cloudwatch_log_group" "ecs_logs" { name = var.ecs_task_cw_logs_group_name retention_in_days = var.ecs_cw_retention_days } # Create an ECS task definition. resource "aws_ecs_task_definition" "ecs_task_definition" { family = "${var.ecs_service_name}-ecs-demo-app" network_mode = var.ecs_task_network_mode requires_compatibilities = ["EC2"] container_definitions = <