gpt4 book ai didi

amazon-web-services - 地形 (AWS) : How to get DNS name of Load Balancer by its ARN?

转载 作者:行者123 更新时间:2023-12-05 01:16:05 25 4
gpt4 key购买 nike

我创建了一个部署 Lambda 函数和目标组的 Terraform 脚本,并将其分配给在变量中定义的现有负载均衡器:

variable "load_balancer_arn" {
default = "arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxx:loadbalancer/app/xx-test/xxxxxxxxxxx"
}

有没有办法通过输出获取此负载均衡器的 DNS 名称?

最佳答案

aws_lb data source对于采用 arn 的 NLB 和 ALB lb 数据资源:

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}

对于最新的 terraform(此时 tf 0.13)你不使用大括号,所以它变成:

data "aws_lb" "test" {
arn = var.lb_arn
}

data.aws_lb.test.dns_name

关于amazon-web-services - 地形 (AWS) : How to get DNS name of Load Balancer by its ARN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54413723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com