Skip to content

Commit

Permalink
fixes minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
anik3tra0 committed Jan 30, 2024
1 parent eb7511d commit 282efd0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
13 changes: 5 additions & 8 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
Expand All @@ -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
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand Down
6 changes: 1 addition & 5 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 282efd0

Please sign in to comment.