【发布时间】:2020-02-12 03:08:11
【问题描述】:
我正在尝试从地图中获取值,它给出了以下错误。
错误:
Error: Incorrect attribute value type
on ../../modules/lb-rules/rules.tf line 71, in resource "aws_alb_listener_rule" "http_header":
71: http_header_name = keys(lookup(var.listener_rules, "http_header_name", null))
|----------------
| var.listener_rules is object with 3 attributes
Inappropriate value for attribute "http_header_name": string required.
main.tf
module example {
...
...
listener_rules = {
...
"http_header_name" = {
"x-header" = "sample_server"
}
}
...
}
rules.tf
resource "aws_alb_listener_rule" http_header {
listener_arn = var.public_alb_listener_arn
priority = var.priority_number
action {
type = "forward"
target_group_arn = aws_alb_target_group.default.id
}
dynamic "condition" {
for_each = lookup(var.listener_rules, "http_header_name", null)
content {
http_header {
http_header_name = keys(lookup(var.listener_rules, "http_header_name", null))
values = ["hi"]
}
}
}
}
【问题讨论】:
-
keys(lookup(var.listener_rules, "http_header_name", null))正在返回一个数组并且参数需要一个字符串类型。
标签: terraform terraform-provider-aws