【问题标题】:Terraform variables defaults and description for nested valuesTerraform 变量默认值和嵌套值的描述
【发布时间】:2021-10-09 04:08:10
【问题描述】:

是否有一个选项可以为 terraform 中的嵌套变量设置默认值和描述?

例子:

variable "example_page_rule"{
      type = list(object({
            level = string,
            tags = string,
            prefix = string    
      }))   
}

这可以实现吗?

variable "example_page_rule"{
          type = list(object({
                level = string, default = "1", description = "debug level 0-7"
                tags = string, default = {}, description = "tags"
                prefix = string, default = "abc", description = "some description"    
          }))   
    }

【问题讨论】:

    标签: amazon-web-services azure google-cloud-platform terraform hcl


    【解决方案1】:

    您可以使用 TF 的新 实验功能 defaults 为您的地图设置默认值。它的语法不同,但结果相同。不过没有描述。

    如果您不想使用体验功能,则必须开发用于处理默认值的自定义代码,就像现在使用的任何其他 TF 代码一样。 here 就是一个例子。

    【讨论】:

    • 可以在自定义代码中添加描述吗?在示例中分配了默认值,但没有为每个值分配描述
    • @Vidya 没有个别字段的描述。你只有description for the entire variable
    猜你喜欢
    • 1970-01-01
    • 2021-05-22
    • 2017-01-02
    • 2020-05-11
    • 2018-02-20
    • 1970-01-01
    • 2020-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多