【问题标题】:Exclude a file in terraform module source排除 terraform 模块源中的文件
【发布时间】:2018-07-21 03:57:56
【问题描述】:

在模块中指定源时是否可以排除.tf 文件。

示例

foo/bar由多个.tf文件组成:

  • file1.tf
  • file2.tf
  • file3.tf

是否可以排除file1.tf,同时在源代码中包含foo/bar,如下所示:

module "module1" {
  source = "foo/bar"
  version = "0.1.0"
}

【问题讨论】:

  • 不,但我猜你可以将资源计数设置为 0?或者你可以有嵌套模块,你有一个子模块和一个父模块,有时你只是直接调用子模块并忽略父模块中的额外内容。你有更具体的例子吗?

标签: terraform


【解决方案1】:

没有明确支持您要求的内容。 You can use some of the workarounds detailed in this Medium post,例如将资源的count 设置为等于您设置为布尔值truefalse 的变量:

file1.tf:

resource "aws_eip" "example" {
  count = "${var.create_eip}"
  ...
}

依赖来源:

module "module1" {
  source = "foo/bar"
  version = "0.1.0"
  create_eip = false  # set to 'true' to include the resource in file1.tf
}

【讨论】:

    猜你喜欢
    • 2019-04-11
    • 1970-01-01
    • 1970-01-01
    • 2016-01-29
    • 1970-01-01
    • 1970-01-01
    • 2020-09-16
    • 2021-12-17
    • 2020-07-09
    相关资源
    最近更新 更多