【问题标题】:Use extraHosts block in Terraform for ECS在 Terraform for ECS 中使用 extraHosts 块
【发布时间】:2020-07-07 20:57:56
【问题描述】:

所以我有一个 ecs-task-definition,我想向容器中的 hosts 文件添加一个值。这可以使用 extraHosts 块来完成:

extraHosts: A list of hostnames and IP address mappings to append to the /etc/hosts file on the container list(string)

请参阅here 了解更多信息。

我试图让这个 extraHosts 块在上面链接的 terraform-aws-ecs-task-definition 模块中运行。我的块看起来像这样:

  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.

过去是否有人将 extraHosts 块用于他们的 IaC?能否请教一下正确的语法?

【问题讨论】:

    标签: amazon-web-services terraform amazon-ecs terraform-provider-aws


    【解决方案1】:

    模块要求输入错误的类型。当您尝试传递 list(object(...)) 时,模块的 extraHosts 变量需要 list(string))。

    https://github.com/mongodb/terraform-aws-ecs-task-definition/issues/33 已经存在问题,但在模块中将类型切换为 list(any) 或更准确地说,list(object([ipAddress = string, hostname = string])) 应该可以解决它。

    【讨论】:

    • 这个 Git 问题的好地方。现在工作正常,谢谢。
    【解决方案2】:

    抱歉,回复延迟。我已编写更改以解决此问题。该修复适用于v2.1.1

    【讨论】:

      猜你喜欢
      • 2019-05-31
      • 1970-01-01
      • 2020-04-10
      • 2020-07-19
      • 1970-01-01
      • 2020-11-23
      • 1970-01-01
      • 2021-06-26
      • 1970-01-01
      相关资源
      最近更新 更多