我创建了一个Terraform脚本,该脚本部署了Lambda函数和目标组,并将其分配给在变量中定义的现有负载均衡器:
variable "load_balancer_arn" {
default = "arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxx:loadbalancer/app/xx-test/xxxxxxxxxxx"
}
是否可以通过输出获取此负载均衡器的DNS名称?
答案 0 :(得分:0)
有aws_lb
data source for NLB和ALB lb数据资源采用了arn:
data "aws_lb" "test" {
arn = "${var.lb_arn}"
}
这将返回以下负载均衡器属性:
Attributes Reference
The following attributes are exported in addition to the arguments listed above:
id - The ARN of the load balancer (matches arn).
arn - The ARN of the load balancer (matches id).
arn_suffix - The ARN suffix for use with CloudWatch Metrics.
dns_name - The DNS name of the load balancer.
zone_id - The canonical hosted zone ID of the load balancer (to be used in a Route 53 Alias record).
这包括dns名称以供使用:
${data.aws_lb.test.dns_name}