From 64fed46119c01d59a440c578c4471943e000d6d3 Mon Sep 17 00:00:00 2001 From: Andrej Golis Date: Thu, 16 May 2024 10:18:45 +0400 Subject: [PATCH 1/4] Fix #6 Change user data var population by join function. Ref.: https://developer.hashicorp.com/terraform/language/functions/join --- ecs-ec2.tf | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ecs-ec2.tf b/ecs-ec2.tf index 3901735..1765087 100644 --- a/ecs-ec2.tf +++ b/ecs-ec2.tf @@ -38,20 +38,20 @@ locals { logstash_env_container = [for k, v in module.services_configuration_merge.merged.logstash.env : { name = k, value = v }] # ECS EC2 configuration - user_data = <<-EOT - #!/bin/bash - - cat <<'EOF' >> /etc/ecs/ecs.config - ECS_CLUSTER=${module.label.id} - ECS_LOGLEVEL=debug - ECS_CONTAINER_INSTANCE_TAGS=${jsonencode(module.label.tags)} - ECS_ENABLE_TASK_IAM_ROLE=true - ECS_ENABLE_HIGH_DENSITY_ENI=true - ECS_ENABLE_SPOT_INSTANCE_DRAINING=true - ECS_ENGINE_AUTH_TYPE=dockercfg - ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), ""))} # pragma: allowlist secret - EOF - EOT + user_data = join("\n", [ + "#!/bin/bash", + "", + "cat <<'EOF' >> /etc/ecs/ecs.config", + "ECS_CLUSTER=${module.label.id}", + "ECS_LOGLEVEL=debug", + "ECS_CONTAINER_INSTANCE_TAGS=${jsonencode(module.label.tags)}", + "ECS_ENABLE_TASK_IAM_ROLE=true", + "ECS_ENABLE_HIGH_DENSITY_ENI=true", + "ECS_ENABLE_SPOT_INSTANCE_DRAINING=true", + "ECS_ENGINE_AUTH_TYPE=dockercfg", + "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), \"\"))}", # pragma: allowlist secret + "EOF" + ]) } module "alb" { From 4fbbcb22f7dcf7d395cb2077f7eb58bab9e61432 Mon Sep 17 00:00:00 2001 From: Andrej Golis Date: Thu, 16 May 2024 10:31:05 +0400 Subject: [PATCH 2/4] #6 Move comment outside of expression --- ecs-ec2.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ecs-ec2.tf b/ecs-ec2.tf index 1765087..81cc882 100644 --- a/ecs-ec2.tf +++ b/ecs-ec2.tf @@ -49,9 +49,10 @@ locals { "ECS_ENABLE_HIGH_DENSITY_ENI=true", "ECS_ENABLE_SPOT_INSTANCE_DRAINING=true", "ECS_ENGINE_AUTH_TYPE=dockercfg", - "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), \"\"))}", # pragma: allowlist secret + "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), \"\"))}", "EOF" ]) + # pragma: allowlist secret } module "alb" { From e6709192539dd8365a01029b45f700d945f01350 Mon Sep 17 00:00:00 2001 From: Andrej Golis Date: Thu, 16 May 2024 10:43:41 +0400 Subject: [PATCH 3/4] #6 Remove backslash typo --- ecs-ec2.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-ec2.tf b/ecs-ec2.tf index 81cc882..6c3e1f1 100644 --- a/ecs-ec2.tf +++ b/ecs-ec2.tf @@ -49,7 +49,7 @@ locals { "ECS_ENABLE_HIGH_DENSITY_ENI=true", "ECS_ENABLE_SPOT_INSTANCE_DRAINING=true", "ECS_ENGINE_AUTH_TYPE=dockercfg", - "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), \"\"))}", + "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), ""))}", "EOF" ]) # pragma: allowlist secret From 710e24d755d92c41df60e46633134086104c2b5d Mon Sep 17 00:00:00 2001 From: Andrej Golis Date: Thu, 16 May 2024 10:48:48 +0400 Subject: [PATCH 4/4] #6 Format block as tflinter --- ecs-ec2.tf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ecs-ec2.tf b/ecs-ec2.tf index 6c3e1f1..5463735 100644 --- a/ecs-ec2.tf +++ b/ecs-ec2.tf @@ -39,20 +39,20 @@ locals { # ECS EC2 configuration user_data = join("\n", [ - "#!/bin/bash", - "", - "cat <<'EOF' >> /etc/ecs/ecs.config", - "ECS_CLUSTER=${module.label.id}", - "ECS_LOGLEVEL=debug", - "ECS_CONTAINER_INSTANCE_TAGS=${jsonencode(module.label.tags)}", - "ECS_ENABLE_TASK_IAM_ROLE=true", - "ECS_ENABLE_HIGH_DENSITY_ENI=true", - "ECS_ENABLE_SPOT_INSTANCE_DRAINING=true", - "ECS_ENGINE_AUTH_TYPE=dockercfg", - "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), ""))}", - "EOF" + "#!/bin/bash", + "", + "cat <<'EOF' >> /etc/ecs/ecs.config", + "ECS_CLUSTER=${module.label.id}", + "ECS_LOGLEVEL=debug", + "ECS_CONTAINER_INSTANCE_TAGS=${jsonencode(module.label.tags)}", + "ECS_ENABLE_TASK_IAM_ROLE=true", + "ECS_ENABLE_HIGH_DENSITY_ENI=true", + "ECS_ENABLE_SPOT_INSTANCE_DRAINING=true", + "ECS_ENGINE_AUTH_TYPE=dockercfg", + "ECS_ENGINE_AUTH_DATA=${sensitive(try(base64decode(var.ecs_registry_auth_data), ""))}", + "EOF" ]) - # pragma: allowlist secret + # pragma: allowlist secret } module "alb" {