Skip to content

Default Target-Group of a listener cant be modified #57

@egarbi

Description

@egarbi

Terraform Version

Terraform v0.11.4

Terraform Configuration Files

module "ECS_ALB" {
  source  = "terraform-aws-modules/alb/aws"
  version = "3.1.0"

  load_balancer_name         = "${var.name}-${var.environment}"
  subnets                    = "${module.vpc.private_subnets}"
  load_balancer_is_internal  = "true"
  security_groups            = ["${module.security_groups.internal_elb}"]
  vpc_id                     = "${module.vpc.vpc_id}"
  enable_deletion_protection = true

  # Listener
  http_tcp_listeners_count = "1"
  http_tcp_listeners       = "${list(map("port", "8080", "protocol", "HTTP"))}"

  // Default Target-Group
  target_groups       = "${list(map("name", "first-${var.environment}", "backend_protocol", "HTTP", "backend_port", "8080"))}"
  target_groups_count = "1"

  #
  // Logging
  log_bucket_name = "${var.name}-${var.environment}-share-alb-logs"

  //Tagging
  tags = {
    Name = "${var.name}"

    Environment = "${var.environment}"
  }
}

Expected Behavior

The module should allow modify the default target-group (rule) associated with a listener.
For this particular example, let's suppose that I have already created a listener with the target-group first-testing as default and I want to change it to be default-testing.

Actual Behavior

Terraform apply fails with the following message:

module.stack.module.ECS_ALB.aws_lb_target_group.main: Destroying... (ID: arn:aws:elasticloadbalancing:us-west-4:...tgroup/first-testing/6f58a25341942b21)

Error: Error applying plan:

1 error(s) occurred:

* module.stack.module.ECS_ALB.aws_lb_target_group.main (destroy): 1 error(s) occurred:

* aws_lb_target_group.main: Error deleting Target Group: ResourceInUse: Target group 'arn:aws:elasticloadbalancing:us-west-4:12345678910:targetgroup/first-testing/6f58a25341942b21' is currently in use by a listener or a rule

Steps to Reproduce

  1. create the resources using the configuration file above, init, plan and apply
  2. modify the default target group as follow:
17c17
<   target_groups                 = "${list(map("name", "first-${var.environment}", "backend_protocol", "HTTP", "backend_port", "8080"))}"
---
>   target_groups                 = "${list(map("name", "default-${var.environment}", "backend_protocol", "HTTP", "backend_port", "8080"))}"
  1. plan
  2. apply

Maybe adding 'lifecycle {crate_before_destroy => true}` into aws_lb_target_group to solve it?
I will test later better

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions