When I do terraform apply every time the desired count is changing from 1 -> 2. Please suggest.
But in variables.tf, I declared as desired_count=2.
~ resource "aws_ecs_service" "ecs_service" {
cluster = "arn:aws:ecs::cluster/"
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 100
~ desired_count = 1 -> 2
enable_ecs_managed_tags = false
force_new_deployment = true
health_check_grace_period_seconds = 0
iam_role = "aws-service-role"
id = "arn:aws:ecs:-ecs-service"
launch_type = "FARGATE"
name = "ecs-service"
platform_version = "LATEST"
propagate_tags = "NONE"
scheduling_strategy = "REPLICA"
tags = {}
task_definition = "arn:aws:ecs:"
deployment_controller {
type = "ECS"
}
load_balancer {
container_name = "abcd"
container_port = 80
target_group_arn = "arn.*"
}
network_configuration {
assign_public_ip = false
security_groups = []
subnets = []
}
}
Here is the main.tf:- Note:- I am using modules to invoke main.tf.
############ ECS Service ##############
resource "aws_ecs_service" "ecs_service" {
name = "${var.name}-ecs-service"
cluster = var.cluster_id
task_definition = var.task_definition_arn
desired_count = var.desired_count
iam_role = var.ecs_iam_role
force_new_deployment = var.force_new_deployment
launch_type = "FARGATE"
deployment_controller {
type = "ECS"
}
deployment_maximum_percent = "200"
deployment_minimum_healthy_percent = "100"
load_balancer {
target_group_arn = var.lb_tg_arn
container_name = var.name
container_port = var.port
}
network_configuration {
security_groups = var.security_group_id
subnets = var.subnets
assign_public_ip = var.assign_public_ip
}
depends_on = [var.aws_alb]
}
Variables are assigned on the requirement of my project by making default=null