From 282efd0913ed6eccb93da6e90a2380e99a0fef6c Mon Sep 17 00:00:00 2001 From: Aniket Rao Date: Tue, 30 Jan 2024 14:53:58 +0530 Subject: [PATCH] fixes minor improvements --- terraform/main.tf | 13 +++++-------- terraform/outputs.tf | 2 +- terraform/variables.tf | 6 +----- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 0f17260..f9d4dff 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -51,7 +51,7 @@ resource "aws_iam_role_policy_attachment" "ecs_task_policy_attachment" { policy_arn = aws_iam_policy.ecs_task_policy.arn } -resource "aws_ecs_task_definition" "my_task" { +resource "aws_ecs_task_definition" "last9-prom-service-discovery-task" { family = "my-task" network_mode = "awsvpc" requires_compatibilities = ["FARGATE"] @@ -63,9 +63,6 @@ resource "aws_ecs_task_definition" "my_task" { container_definitions = jsonencode([{ name = "my-container", image = var.docker_image, - portMappings = [{ - containerPort = var.container_port - }], mountPoints = [{ sourceVolume = "efs-volume", containerPath = var.efs_mount_path @@ -86,15 +83,15 @@ resource "aws_ecs_task_definition" "my_task" { # IAM roles and policies # ... (Define aws_iam_role.ecs_execution_role and aws_iam_role.ecs_task_role here) -resource "aws_ecs_service" "my_service" { +resource "aws_ecs_service" "last9-prom-service-discovery-service" { name = "my-service" cluster = aws_ecs_cluster.my_cluster.id - task_definition = aws_ecs_task_definition.my_task.arn + task_definition = aws_ecs_task_definition.last9-prom-service-discovery-task.arn launch_type = "FARGATE" network_configuration { subnets = var.subnet_ids - security_groups = [aws_security_group.ecs_sg.id] + security_groups = [aws_security_group.last9-prom-sd_ecs_sg.id] assign_public_ip = true } @@ -105,7 +102,7 @@ resource "aws_ecs_service" "my_service" { # ... (Define aws_efs_file_system.my_efs and related resources here) # Security groups -resource "aws_security_group" "ecs_sg" { +resource "aws_security_group" "last9-prom-sd_ecs_sg" { name = "ecs-sg" description = "Security group for ECS service" vpc_id = var.vpc_id diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 56ec3f3..1d6fea3 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -1,5 +1,5 @@ output "ecs_service_name" { - value = aws_ecs_service.my_service.name + value = aws_ecs_service.last9-prom-service-discovery-service.name } output "efs_id" { diff --git a/terraform/variables.tf b/terraform/variables.tf index d506018..4172aa8 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -13,14 +13,10 @@ variable "docker_image" { type = string } -variable "container_port" { - description = "The port on which the container is listening" - type = number -} - variable "efs_mount_path" { description = "Mount path for the EFS volume in the container" type = string + default = "/efs/mnt" } variable "subnet_ids" {