hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.83k stars 9.18k forks source link

Updating the desired count of an ECS Service is throwing an error. #36727

Open Prabhanjali opened 7 months ago

Prabhanjali commented 7 months ago

Description

I am trying to update the desired count of my ECS Service. When I am trying to do this, I am getting the Below Error.

ERROR: error updating ECS Service: InvalidParameterException: Unable to update network parameters on services with a CODE_DEPLOY deployment controller. Use AWS CodeDeploy to trigger a new deployment.

our terraform Configuration follows like this.

resource "aws_ecs_service" "my_service" {
  name                    = "my-service"
  cluster                      = aws_ecs_cluster.my_cluster.id
  task_definition     = aws_ecs_task_definition.my_task_definition.arn
  desired_count          = 2
  launch_type             = "FARGATE"
  deployment_controller {
    type                    = "CODE_DEPLOY"
  }
  dynamic network_configuration {
    for_each = task_definition.my_task_definition.network_mode == "awsvpc" ? [1] : []
    content{
        subnets = ["subnet-xxxxxxxxx", "subnet-xxxxxxxx"]  
        security_groups = ["sg-xxxxxxxxx"]
    }
    }
}

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 7 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 7 months ago

Hey @Prabhanjali 👋 Thank you for taking the time to raise this! Can you clarify what you're using for for_each in the dynamic block? It doesn't look like the configuration is valid at the moment.

Prabhanjali commented 7 months ago

there for_each dynamic block we will add the compute subnets for that task definition if the network_mode is "awsvpc"