Skip to content

Commit

Permalink
Fixed passing of i/o variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronaldo Macapobre committed Jul 25, 2024
1 parent abebde8 commit 81d0e86
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 25 deletions.
20 changes: 11 additions & 9 deletions infrastructure/cloud/environments/sandbox/webapp.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


module "security" {
source = "../../modules/security"
environment = var.environment
Expand All @@ -17,15 +15,19 @@ module "storage" {
depends_on = [module.security]
}

module "container" {
source = "../../modules/container"
environment = var.environment
app_name = var.app_name
depends_on = [module.security, module.networking]
}

module "networking" {
source = "../../modules/networking"
environment = var.environment
app_name = var.app_name
}

module "container" {
source = "../../modules/container"
environment = var.environment
app_name = var.app_name
ecs_task_execution_iam_role_arn = module.security.ecs_task_execution_iam_role_arn
subnet_private_id = module.networking.subnet_private_id
ecs_sg_id = module.networking.ecs_sg_id
lb_listener = module.networking.lb_listener
lb_tg_arn = module.networking.lb_tg_arn
}
12 changes: 6 additions & 6 deletions infrastructure/cloud/modules/container/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ resource "aws_ecs_task_definition" "ecs_task_definition" {
}
])

execution_role_arn = module.security.ecs_task_execution_iam_role_arn
task_role_arn = module.security.ecs_task_execution_iam_role_arn
execution_role_arn = var.ecs_task_execution_iam_role_arn
task_role_arn = var.ecs_task_execution_iam_role_arn
}

resource "aws_ecs_service" "ecs_service" {
Expand All @@ -39,16 +39,16 @@ resource "aws_ecs_service" "ecs_service" {
desired_count = 1

network_configuration {
subnets = module.networking.subnet_private_id
security_groups = [module.networking.ecs_sg_id]
subnets = var.subnet_private_id
security_groups = [var.ecs_sg_id]
assign_public_ip = false
}

load_balancer {
target_group_arn = module.networking.lb_tg_arn
target_group_arn = var.lb_tg_arn
container_name = "${var.app_name}-container-${var.environment}"
container_port = 80
}

depends_on = [module.networking.lb_listener]
depends_on = [var.lb_listener]
}
3 changes: 1 addition & 2 deletions infrastructure/cloud/modules/container/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
output "ecr_url" {
description = "The ECR URL."
value = try(aws_ecr_repository.ecr_repository.repository_url, "")
value = try(aws_ecr_repository.ecr_repository.repository_url, "")
}
20 changes: 20 additions & 0 deletions infrastructure/cloud/modules/container/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@ variable "app_name" {
description = "The name of the application"
type = string
}

variable "ecs_task_execution_iam_role_arn" {
description = "ECS Task Execution IAM Role ARN"
}

variable "subnet_private_id" {
description = "Private Subnet ID"
}

variable "ecs_sg_id" {
description = "ECS Security Group ID"
}

variable "lb_tg_arn" {
description = "Load Balancer Target Group ARN"
}

variable "lb_listener" {
description = "Load Balancer Listener"
}
12 changes: 4 additions & 8 deletions infrastructure/cloud/modules/networking/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
output "subnet_private_id" {
description = "Private Subnet ID"
value = aws_subnet.private[*].id
value = aws_subnet.private[*].id
}

output "ecs_sg_id" {
description = "ECS Security Group ID"
value = aws_security_group.ecs_security_group.id
value = aws_security_group.ecs_security_group.id
}

output "lb_tg_arn" {
description = "Load Balancer Target Group ARN"
value = aws_lb_target_group.lb_target_group.arn
value = aws_lb_target_group.lb_target_group.arn
}

output "lb_listener" {
description = "Load Balancer Listener"
value = aws_lb_listener.lb_listener
value = aws_lb_listener.lb_listener
}

0 comments on commit 81d0e86

Please sign in to comment.