微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在terraform 12/13中作为模块属性动态传递地图?

如何解决在terraform 12/13中作为模块属性动态传递地图?

问题

如何动态地将地图解压缩到模块/资源属性中?我了解您可以执行dynamic resource attributes blocks in terraform 12/13,但是可以为整个资源/模块的所有属性执行此操作吗?例如:

module "this" {
  for_each = {
    att0 = "attr0"
    attr1 = "attr1"
    attr2 = "attr2"
  }

  each.key = each.value
}

# my hope is that this would do the equivalent of this code below

module "this" {
  attr0 = "attr0"
  attr1 = "attr1"
  attr2 = "attr2"
}

类似于您将splat kwargs转换为函数时在python中的操作方式。例如

# python3
kwargs = {"foo": "bar","bar": "foo"}
my_func(**kwargs)

我尝试过的其他变化形式:

module "this" {
  for_each = {
    att0 = "attr0"
    attr1 = "attr1"
    attr2 = "attr2"
  }
}
module "this" {
  {
    att0 = "attr0"
    attr1 = "attr1"
    attr2 = "attr2"
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。