diff --git a/env/prod/main.tf b/env/prod/main.tf index 9932692..60658cc 100644 --- a/env/prod/main.tf +++ b/env/prod/main.tf @@ -22,18 +22,18 @@ data "aws_ecr_repository" "repository" { locals { app_name = "aluraflix" # VPC - vpc_id = module.vpc.vpc_id - vpc_cidr = "10.0.0.0/16" - vpc_subnets = module.vpc.subnets - vpc_azs = slice(data.aws_availability_zones.available.names, 0, 2) - + vpc_id = module.vpc.vpc_id + vpc_cidr = "10.0.0.0/16" + vpc_subnets = module.vpc.subnets + vpc_azs = slice(data.aws_availability_zones.available.names, 0, 2) + # Security Groups sg_allow_http = module.vpc.sg_allow_http_id sg_dafault = module.vpc.sg_default_id - + # Auto Scalling - asg_arn = module.ec2.asg_arn - + asg_arn = module.ec2.asg_arn + # Load Balancer lb_target_group = module.ec2.lb_target_group } diff --git a/infra/ecs/main.tf b/infra/ecs/main.tf index 95f4095..0de10e9 100644 --- a/infra/ecs/main.tf +++ b/infra/ecs/main.tf @@ -15,7 +15,7 @@ resource "aws_ecs_cluster" "cluster" { } resource "aws_ecs_capacity_provider" "capacity_provider" { - name = "capacity-provider-${var.name}" + name = var.capacity_name auto_scaling_group_provider { auto_scaling_group_arn = var.asg_arn @@ -76,7 +76,7 @@ resource "aws_ecs_task_definition" "ecs_task_definition" { } resource "aws_ecs_service" "service" { - name = "service-${var.name}" + name = var.service_name cluster = aws_ecs_cluster.cluster.id task_definition = aws_ecs_task_definition.ecs_task_definition.arn desired_count = 2 diff --git a/infra/ecs/variables.tf b/infra/ecs/variables.tf index 732b505..9c0242f 100644 --- a/infra/ecs/variables.tf +++ b/infra/ecs/variables.tf @@ -17,6 +17,18 @@ variable "container_name" { type = string } +variable "cluster_name" { + type = string +} + +variable "capacity_name" { + type = string +} + +variable "service_name" { + type = string +} + variable "asg_arn" { type = string } @@ -29,6 +41,3 @@ variable "subnets" { default = null } -variable "cluster_name" { - type = string -}