Skip to content

Commit

Permalink
changed relayers_name to nodes_name (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
eedygreen authored Mar 8, 2024
1 parent 76c328a commit 9c4891c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion modules/relayers/cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_cloudwatch_log_group" "logs" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "/ecs/${var.project_name}-${each.key}-${var.env_sufix}"
retention_in_days = var.log_retention_days
tags = {
Expand Down
12 changes: 6 additions & 6 deletions modules/relayers/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ locals {
}

resource "aws_ecs_task_definition" "main" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
network_mode = "awsvpc"
family = "${var.project_name}-${each.key}-container-${var.env_sufix}"
requires_compatibilities = ["FARGATE"]
Expand Down Expand Up @@ -56,7 +56,7 @@ resource "aws_ecs_task_definition" "main" {
}

resource "aws_ecs_service" "main" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-service-${upper(var.env_sufix)}"
cluster = length(data.aws_ecs_cluster.cluster_exist.arn) > 0 ? data.aws_ecs_cluster.cluster_exist.arn : local.aws_ecs_cluster_main
desired_count = 1
Expand Down Expand Up @@ -106,7 +106,7 @@ resource "aws_service_discovery_private_dns_namespace" "ecs-service-namespace" {
}
}
resource "aws_service_discovery_service" "ecs-service-discovery" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}"

dns_config {
Expand All @@ -130,7 +130,7 @@ resource "aws_service_discovery_service" "ecs-service-discovery" {
}

resource "aws_appautoscaling_target" "ecs_target" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
max_capacity = var.app_max_capacity
min_capacity = 1
resource_id = "service/${length(data.aws_ecs_cluster.cluster_exist.arn) > 0 ? data.aws_ecs_cluster.cluster_exist.arn : local.aws_ecs_cluster_main}/${aws_ecs_service.main[each.key].name}"
Expand All @@ -139,7 +139,7 @@ resource "aws_appautoscaling_target" "ecs_target" {
}

resource "aws_appautoscaling_policy" "ecs_policy_memory" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "memory-autoscaling"
policy_type = "TargetTrackingScaling"
resource_id = aws_appautoscaling_target.ecs_target[each.key].resource_id
Expand All @@ -155,7 +155,7 @@ resource "aws_appautoscaling_policy" "ecs_policy_memory" {
}

resource "aws_appautoscaling_policy" "ecs_policy_cpu" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "cpu-autoscaling"
policy_type = "TargetTrackingScaling"
resource_id = aws_appautoscaling_target.ecs_target[each.key].resource_id
Expand Down
12 changes: 6 additions & 6 deletions modules/relayers/iam.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_iam_role" "ecs_task_role" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-ecsTaskRole"

assume_role_policy = <<EOF
Expand All @@ -25,7 +25,7 @@ EOF
}

resource "aws_iam_policy" "task_policy" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-task-policy"
path = "/"
description = "Task App policy"
Expand Down Expand Up @@ -62,7 +62,7 @@ resource "aws_iam_policy" "task_policy" {
}

resource "aws_iam_role_policy_attachment" "ecs-task-role-policy-attachment" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
role = aws_iam_role.ecs_task_role[each.key].name
policy_arn = aws_iam_policy.task_policy[each.key].arn
}
Expand All @@ -72,7 +72,7 @@ resource "aws_iam_role_policy_attachment" "ecs-task-role-policy-attachment" {
###

resource "aws_iam_role" "ecs_task_execution_role" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-ecsTaskExecutionRole"

assume_role_policy = <<EOF
Expand All @@ -98,13 +98,13 @@ EOF
}

resource "aws_iam_role_policy_attachment" "ecs-task-execution-role-policy-attachment" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
role = aws_iam_role.ecs_task_execution_role[each.key].name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
}

resource "aws_iam_role_policy_attachment" "ecs-ssm-role-policy-attachment" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
role = aws_iam_role.ecs_task_execution_role[each.key].name
policy_arn = aws_iam_policy.task_policy[each.key].arn
}
12 changes: 6 additions & 6 deletions modules/relayers/nlb.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_lb" "main" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-lb-${var.env_sufix}"
internal = var.is_lb_internal
load_balancer_type = "network"
Expand All @@ -12,7 +12,7 @@ resource "aws_lb" "main" {
}

resource "aws_lb_target_group" "http" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-http"
depends_on = [
aws_lb.main
Expand All @@ -38,7 +38,7 @@ resource "aws_lb_target_group" "http" {
}

resource "aws_lb_target_group" "tcp" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
name = "${var.project_name}-${each.key}-tcp"
depends_on = [
aws_lb.main
Expand Down Expand Up @@ -66,7 +66,7 @@ resource "aws_lb_target_group" "tcp" {


resource "aws_lb_listener" "http" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
load_balancer_arn = aws_lb.main[each.key].id
port = 9001
protocol = "TCP"
Expand All @@ -78,7 +78,7 @@ resource "aws_lb_listener" "http" {
}

resource "aws_lb_listener" "tcp" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
load_balancer_arn = aws_lb.main[each.key].id
port = var.internal_app_container_port
protocol = "TCP"
Expand All @@ -90,7 +90,7 @@ resource "aws_lb_listener" "tcp" {
}

resource "aws_lb_listener" "tls" {
for_each = toset(var.relayers_name)
for_each = toset(var.nodes_name)
load_balancer_arn = aws_lb.main[each.key].id
port = "443"
protocol = "TLS"
Expand Down
2 changes: 1 addition & 1 deletion modules/relayers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ variable "internal_app_container_port" {}
variable "external_app_container_port" {}
variable "efs_port" {}
variable "app_image" {}
variable "relayers_name" {}
variable "nodes_name" {}
variable "certificate_domain" {}
variable "tg_health_check_path" {}
variable "tg_target_type" {}
Expand Down

0 comments on commit 9c4891c

Please sign in to comment.