diff --git a/data.tf b/data.tf index 028f92d..701092b 100644 --- a/data.tf +++ b/data.tf @@ -1,3 +1,3 @@ data "aws_security_group" "proxy" { id = var.proxy_security_group -} \ No newline at end of file +} diff --git a/example/container/container_definition.json.tftpl b/example/container/container_definition.json.tftpl index cb7af0a..447a127 100644 --- a/example/container/container_definition.json.tftpl +++ b/example/container/container_definition.json.tftpl @@ -22,4 +22,4 @@ } } } -] \ No newline at end of file +] diff --git a/example/container/execution_role.json b/example/container/execution_role.json index 8dc41cc..293e28a 100644 --- a/example/container/execution_role.json +++ b/example/container/execution_role.json @@ -15,4 +15,4 @@ "Resource": "*" } ] - } \ No newline at end of file + } diff --git a/example/iam.tf b/example/iam.tf index 4b2014b..99b0937 100644 --- a/example/iam.tf +++ b/example/iam.tf @@ -5,9 +5,9 @@ resource "aws_iam_role_policy" "policies" { role = module.aws_service.task_role_id policy = templatefile("${path.module}/container/task_role/${each.value}", { - aws_region = var.region - aws_account = var.aws_account - environment = var.environment + aws_region = var.region + aws_account = var.aws_account + environment = var.environment }) depends_on = [ diff --git a/example/locals.tf b/example/locals.tf index 06c102f..c727d58 100644 --- a/example/locals.tf +++ b/example/locals.tf @@ -1,4 +1,4 @@ locals { - cluster_name_full = "${var.ecs.cluster_name}-${var.environment}" - service_name_full = "${var.ecs.service_name}-${var.environment}" + cluster_name_full = "${var.ecs.cluster_name}-${var.environment}" + service_name_full = "${var.ecs.service_name}-${var.environment}" } diff --git a/example/outputs.tf b/example/outputs.tf index 44064e4..2bc84d6 100644 --- a/example/outputs.tf +++ b/example/outputs.tf @@ -10,4 +10,3 @@ output "cluster_id" { description = "ECS Cluster ID" value = module.ecs.cluster_id } - diff --git a/modules/ecs-fargate/cloudwatch.tf b/modules/ecs-fargate/cloudwatch.tf index add66af..9b260da 100644 --- a/modules/ecs-fargate/cloudwatch.tf +++ b/modules/ecs-fargate/cloudwatch.tf @@ -2,11 +2,11 @@ resource "aws_cloudwatch_log_group" "proxy" { name = "/aws/ecs/${var.ecs.cluster_name}/${var.ecs.service_name}/${var.environment}" retention_in_days = 90 tags = { - Name = "/aws/ecs/${var.ecs.cluster_name}/${var.ecs.service_name}/${var.environment}", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "/aws/ecs/${var.ecs.cluster_name}/${var.ecs.service_name}/${var.environment}", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } @@ -25,11 +25,11 @@ resource "aws_cloudwatch_metric_alarm" "cpu_high" { alarm_actions = [aws_appautoscaling_policy.scale_up.arn] tags = { - Name = "${local.service_name_full}-cpu-high-alarm", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-cpu-high-alarm", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } // Autoscaling - Alarm CPU Low @@ -47,9 +47,9 @@ resource "aws_cloudwatch_metric_alarm" "cpu_low" { alarm_actions = [aws_appautoscaling_policy.scale_down.arn] tags = { - Name = "${local.service_name_full}-cpu-low-alarm", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-cpu-low-alarm", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } diff --git a/modules/ecs-fargate/iam.tf b/modules/ecs-fargate/iam.tf index 7fec6aa..c3aaedb 100644 --- a/modules/ecs-fargate/iam.tf +++ b/modules/ecs-fargate/iam.tf @@ -3,11 +3,11 @@ resource "aws_iam_role" "task_role" { name = "${local.service_name_full}-task-role" assume_role_policy = data.aws_iam_policy_document.document.json tags = { - Name = "${local.service_name_full}-task-role", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-task-role", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } # The ECS Task Execution role IAM permissions @@ -15,11 +15,11 @@ resource "aws_iam_role" "execution_role" { name = "${local.service_name_full}-execution-role" assume_role_policy = data.aws_iam_policy_document.document.json tags = { - Name = "${local.service_name_full}-execution-role", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-execution-role", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } resource "aws_iam_role_policy" "execution_role" { diff --git a/modules/ecs-fargate/json/container_definition.json.tftpl b/modules/ecs-fargate/json/container_definition.json.tftpl index ab26d5e..5a5eb5f 100644 --- a/modules/ecs-fargate/json/container_definition.json.tftpl +++ b/modules/ecs-fargate/json/container_definition.json.tftpl @@ -23,4 +23,4 @@ } } } -] \ No newline at end of file +] diff --git a/modules/ecs-fargate/json/execution_role.json b/modules/ecs-fargate/json/execution_role.json index 8dc41cc..293e28a 100644 --- a/modules/ecs-fargate/json/execution_role.json +++ b/modules/ecs-fargate/json/execution_role.json @@ -15,4 +15,4 @@ "Resource": "*" } ] - } \ No newline at end of file + } diff --git a/modules/ecs-fargate/lb.tf b/modules/ecs-fargate/lb.tf index b234127..3ddd81d 100644 --- a/modules/ecs-fargate/lb.tf +++ b/modules/ecs-fargate/lb.tf @@ -16,11 +16,11 @@ resource "aws_lb_target_group" "tg" { } } tags = { - Name = "${local.service_name_full}-tg", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-tg", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } resource "aws_lb_listener" "listener" { @@ -33,8 +33,8 @@ resource "aws_lb_listener" "listener" { target_group_arn = aws_lb_target_group.tg.arn } tags = { - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } diff --git a/modules/ecs-fargate/locals.tf b/modules/ecs-fargate/locals.tf index 4da2a0b..3975f6c 100644 --- a/modules/ecs-fargate/locals.tf +++ b/modules/ecs-fargate/locals.tf @@ -1,7 +1,7 @@ locals { - service_name_full = "${var.ecs.service_name}-${var.environment}" - cluster_name_full = "${var.ecs.cluster_name}-${var.environment}" - + service_name_full = "${var.ecs.service_name}-${var.environment}" + cluster_name_full = "${var.ecs.cluster_name}-${var.environment}" + region_code = (var.aws_region == "us-west-1") ? "uw1" : "ue1" task = defaults(var.task, { diff --git a/modules/ecs-fargate/main.tf b/modules/ecs-fargate/main.tf index 8783d00..4f8cb43 100644 --- a/modules/ecs-fargate/main.tf +++ b/modules/ecs-fargate/main.tf @@ -26,11 +26,11 @@ resource "aws_ecs_service" "service" { security_groups = [aws_security_group.ecs.id] } tags = { - Name = "${var.ecs.service_name}-${var.environment}", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${var.ecs.service_name}-${var.environment}", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } propagate_tags = "TASK_DEFINITION" } @@ -57,9 +57,9 @@ resource "aws_ecs_task_definition" "definition" { }) tags = { - Name = "${var.ecs.service_name}-${var.environment}-task-definition", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${var.ecs.service_name}-${var.environment}-task-definition", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } diff --git a/modules/ecs-fargate/sg.tf b/modules/ecs-fargate/sg.tf index fe147a3..2703c4f 100644 --- a/modules/ecs-fargate/sg.tf +++ b/modules/ecs-fargate/sg.tf @@ -20,12 +20,12 @@ resource "aws_security_group" "alb" { } tags = { - Name = "${local.service_name_full}-alb", - Environment = var.environment, - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}", - Description = "Allow HTTP traffic to the application proxy" - owner = "devops" + Name = "${local.service_name_full}-alb", + Environment = var.environment, + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}", + Description = "Allow HTTP traffic to the application proxy" + owner = "devops" } } @@ -51,11 +51,11 @@ resource "aws_security_group" "ecs" { } tags = { - Name = "${local.service_name_full}-ecs", - Environment = var.environment, - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}", - Description = "Allow traffic from the ALB into the Docker containers." - owner = "devops" + Name = "${local.service_name_full}-ecs", + Environment = var.environment, + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}", + Description = "Allow traffic from the ALB into the Docker containers." + owner = "devops" } } diff --git a/modules/ecs-fargate/variables.tf b/modules/ecs-fargate/variables.tf index e648a3c..f1538c3 100644 --- a/modules/ecs-fargate/variables.tf +++ b/modules/ecs-fargate/variables.tf @@ -22,7 +22,7 @@ variable "project" { variable "proxy_security_group" { type = string description = "The associated SG of the Dopple Proxy" - default = none + default = none } # ECS-specific variables diff --git a/modules/ecs-fargate/version.tf b/modules/ecs-fargate/version.tf index 9796a57..318aeda 100644 --- a/modules/ecs-fargate/version.tf +++ b/modules/ecs-fargate/version.tf @@ -7,4 +7,4 @@ terraform { version = ">= 4.0, < 6.0" } } -} \ No newline at end of file +} diff --git a/variables.tf b/variables.tf index 96479ca..306e793 100644 --- a/variables.tf +++ b/variables.tf @@ -22,7 +22,7 @@ variable "project" { variable "proxy_security_group" { type = string description = "The associated SG of the Proxy" - default = none + default = none } # ECS-specific variables diff --git a/version.tf b/version.tf index 9796a57..318aeda 100644 --- a/version.tf +++ b/version.tf @@ -7,4 +7,4 @@ terraform { version = ">= 4.0, < 6.0" } } -} \ No newline at end of file +}