如何将域名添加到我的 Terraform 配置中

How can I add domain names to my terraform configuration

除了路径之外,我还想将域添加到侦听器规则。我应该使用什么参数。

resource "aws_alb_listener_rule" "service" {
  listener_arn = var.alb_listener_arn
  action {
    type             = "forward"
    target_group_arn = aws_alb_target_group.service.arn
  }
  condition {
    path_pattern {
      values = ["/login", "/logout"]
    }
  }

谢谢。

域名指定使用host_header:

Contains a single values item which is a list of host header patterns to match.

来自文档的示例用法:

  condition {
    host_header {
      values = ["my-service.*.terraform.io"]
    }
  }

谢谢。这有效。

condition {
    path_pattern {
      values = ["/login", "/logout"]
    }
}
condition {
    host_header {
      values = ["my-service.*.terraform.io"]
    }
  }