Terraform-provider-aws: [aws_lb_target_group] Validation forces invalid path for TCP health check

Created on 12 Jan 2018  ยท  4Comments  ยท  Source: hashicorp/terraform-provider-aws

It is desirable to be able to configure either a TCP or HTTP/HTTPS health check based on variables as in the below example. Currently the validation forces the health check path to begin with a slash("/"), even when the protocol is TCP, preventing this use case. When the protocol is TCP, blank ("") is the only valid path for the AWS API.

  health_check {
    healthy_threshold   = 2
    unhealthy_threshold = 2
    timeout             = 10
    port                = 8000
    path                = "${var.protocol == "TCP" ? "" : "/healthz"}"
    protocol            = "${var.protocol}"
    interval            = 30
    matcher             = "${var.protocol == "TCP" ? "" : "200-399"}"
  }

Terraform Version

Terraform v0.11.1
+ provider.aws v1.7.0

Affected Resource(s)

  • aws_lb_target_group

Terraform Configuration Files

  health_check {
    healthy_threshold   = 2
    unhealthy_threshold = 2
    timeout             = 10
    port                = 8000
    path                = ""
    protocol            = "TCP"
    interval            = 30
    matcher             = ""
  }

Expected Behavior

Expected to be able to use a blank 'path' for a TCP health check.
Or else the path validation should be left to the AWS API.

Actual Behavior

Error: module.nlb.aws_lb_target_group.nlb[0]: "health_check.0.path" must begin with a '/' character: ""

Steps to Reproduce

  1. Create a aws_lb_target_group with health_check.protocol="TCP" and health_check.path=""
  2. terraform init
  3. terraform apply

References

Validation was recently improved to enable HTTP/HTTPS health checks to be able to be specified for TCP Target Groups in PR #2906.

bug servicelbv2

Most helpful comment

This has been released in terraform-provider-aws version 1.7.1. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

All 4 comments

Looks like there is a fairly trivial fix for this: PR #2980

Only check for "/" if the path is not blank.

This fix is in master and will be released in v1.7.1, which we are planning for later this week.

This has been released in terraform-provider-aws version 1.7.1. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darrenhaken picture darrenhaken  ยท  36Comments

marcincuber picture marcincuber  ยท  39Comments

loivis picture loivis  ยท  41Comments

hashibot picture hashibot  ยท  58Comments

oarmstrong picture oarmstrong  ยท  44Comments