terraform-aws-modules / terraform-aws-alb

Terraform module to create AWS Application/Network Load Balancer (ALB/NLB) resources πŸ‡ΊπŸ‡¦
https://registry.terraform.io/modules/terraform-aws-modules/alb/aws
Apache License 2.0
440 stars 674 forks source link

Can't use TCP as target group health check protocol #386

Open Amarquier opened 1 week ago

Amarquier commented 1 week ago

Description

I'm trying to deploy a NLB with a TCP health check. However I have an error saying I can't set a "matcher" or "path" attribute If using a TCP health check but I don't have these attributes listed in my code. They are defaulting at "null" value in your source code and Terraform is not treating it as null but as if the parameter was set.

Versions

Reproduction Code [Required]

Steps to reproduce the behavior:

Create a network load balancer with the following health_check attribute :

      health_check = {
        enabled             = true
        protocol            = "TCP"
        port                = 7777
        healthy_threshold   = 2
        unhealthy_threshold = 2
        timeout             = 10
        interval            = 30
      }

Expected behavior

The target group should be deployed.

Actual behavior

β”‚ Attribute "health_check[0].matcher" cannot be specified when "health_check[0].protocol" is "TCP". β”‚ health_check[0].path

This is because the source code set these attributes as null if they are not set in the code. From your module main.tf

      matcher             = try(health_check.value.matcher, null)
      path                = try(health_check.value.path, null)
Amarquier commented 1 week ago

After further testing, it seems the issue is because the health check is already created as HTTP. If I try to create a new target group no issue to set the health check protocol as TCP.