在 Terraform for ECS 中使用 extraHosts 块
Use extraHosts block in Terraform for ECS
所以我有一个 ecs-task-definition,我想在我的容器中的主机文件中添加一个值。这可以使用 extraHosts 块来完成:
extraHosts: A list of hostnames and IP address mappings to append to the /etc/hosts file on the container list(string)
有关详细信息,请参阅 here。
我正在尝试在上面链接的 terraform-aws-ecs-task-definition 模块中获取这个 extraHosts 块 运行。我的块看起来像这样:
extraHosts = [
{
"ipAddress": "x.x.x.x",
"hostname": "mongo1"
},
{
"ipAddress": "x.x.x.x",
"hostname": "mongo2"
},
]
但是这个语法让我明白了:
The given value is not suitable for child module variable "extraHosts" defined
at
.terraform/modules/ecs-task-definition/terraform-aws-ecs-task-definition-2.0.1/variables.tf:66,1-22:
element 0: string required.
过去有没有人在他们的 IaC 中使用过 extraHosts 块?你能告诉我正确的语法吗?
模块请求的类型错误。当您试图传递 list(object(...))
).
时,模块的 extraHosts
变量需要 list(string)
https://github.com/mongodb/terraform-aws-ecs-task-definition/issues/33 已经存在问题,但将类型切换为 list(any)
,或者更准确地说,模块中的 list(object([ipAddress = string, hostname = string]))
应该可以解决问题。
抱歉延迟回复。我已经编写了一个更改来解决这个问题。此修复适用于 v2.1.1.
所以我有一个 ecs-task-definition,我想在我的容器中的主机文件中添加一个值。这可以使用 extraHosts 块来完成:
extraHosts: A list of hostnames and IP address mappings to append to the /etc/hosts file on the container list(string)
有关详细信息,请参阅 here。
我正在尝试在上面链接的 terraform-aws-ecs-task-definition 模块中获取这个 extraHosts 块 运行。我的块看起来像这样:
extraHosts = [
{
"ipAddress": "x.x.x.x",
"hostname": "mongo1"
},
{
"ipAddress": "x.x.x.x",
"hostname": "mongo2"
},
]
但是这个语法让我明白了:
The given value is not suitable for child module variable "extraHosts" defined
at
.terraform/modules/ecs-task-definition/terraform-aws-ecs-task-definition-2.0.1/variables.tf:66,1-22:
element 0: string required.
过去有没有人在他们的 IaC 中使用过 extraHosts 块?你能告诉我正确的语法吗?
模块请求的类型错误。当您试图传递 list(object(...))
).
extraHosts
变量需要 list(string)
https://github.com/mongodb/terraform-aws-ecs-task-definition/issues/33 已经存在问题,但将类型切换为 list(any)
,或者更准确地说,模块中的 list(object([ipAddress = string, hostname = string]))
应该可以解决问题。
抱歉延迟回复。我已经编写了一个更改来解决这个问题。此修复适用于 v2.1.1.