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.74k stars 9.1k forks source link

[Bug]: Unable to create ecs service with external controller and loadbalancers configuration block #27291

Open rsmolinski opened 1 year ago

rsmolinski commented 1 year ago

Terraform Core Version

1.3.1

AWS Provider Version

4.35.0

Affected Resource(s)

aws_ecs_service

Expected Behavior

Load balancer is attached to the service

Actual Behavior

Creating ecs service with external deployment controller and load_balancer configuration:

Error: error creating ECS service (test): InvalidParameterException: LoadBalancers must be empty or null.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_ecs_service" "test" {
  name            = "test"
  cluster         = aws_ecs_cluster.tf-test-cluster.id
  desired_count   = 2

  network_configuration {
    security_groups = [aws_security_group.tf-test-tasks.id]
    subnets         = var.vpc_private_subnets
  }

  deployment_controller {
    type = "EXTERNAL"
  }

  load_balancer {
    target_group_arn = aws_alb_target_group.tf-test-tg.arn
    container_name   = "test"
    container_port   = 3000
  }

  depends_on = [
    aws_alb_listener.tf-test-listener
  ]
}

Steps to Reproduce

Deploy ecs service with external deployment controller and configuration block for load balancers

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No response

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

WillGreen commented 1 year ago

I'm having a similar issue that started today (2022-10-18). But our deployment controller type is CodeDeploy:

 deployment_controller {
    type = "CODE_DEPLOY"
  }

In a possibly related issue, we're also seeing issues updating existing ECS services (despite not making any changes to our Terraform configuration). Plan shows no issue, but when we try to apply the plan:

Error: modifying ELBv2 Listener (arn:aws:elasticloadbalancing:us-west-2:****): ValidationError: A target group ARN must be specified

I have retested with Terraform 1.3.2 and AWS Provider 4.35.0 but am still having issues.

ferschubert-hm commented 1 year ago

I am also seeing this, the behavior I have is that previously CodeDeploy kept both targets associated with the ALB listener, with different weights (100% active, 0% secondary) and now the secondary (not active) Target Group is simply removed.

This started somewhere in the last week or so, I do not see changes related to this in the TF AWS provider 4.35.0 so my assumption goes to something changed on AWS CodeDeploy service (but could not find any clear evidence/changelog).