terraform - 在嵌套块中使用计数
问题描述
Terraform 中有没有办法在嵌套块中使用计数参数?我不想创建资源的多个实例,我想使用资源生成动态数量的嵌套块。举个例子:
variable "envNames" {
type = "list"
}
variable "envValues" {
type = "list"
}
resource "test_resource" "example" {
# If length(var.envNames) == 5, I would want 5 env blocks
env {
count = "${length(var.envNames)}"
name = "${element(var.envNames, count.index)}"
value = "${element(var.envValues, count.index)}"
}
}
看起来在 terraform v0.12 中我可以dynamic
在块上使用关键字以及foreach
声明和地图变量,但是在 v0.11 中有没有办法做到这一点?
如果有帮助,这适用于 Kubernetes 部署资源。
解决方案
推荐阅读
- html - 将 Django 模板中的多个文件名传递给 python 中的视图
- c# - 打破 Hub 中的无限循环
- python - 如何从 Paperspace Free GPU 下载 kaggle 数据集
- javascript - 有什么方法可以用 JS 给很多用户创建邮件?
- c# - 如何使用 Coypu 和 C# 获取 InnerText?
- javascript - 如何在反应表中添加新的可编辑文本字段行?
- android - FCM 在我的活动中每次都生成相同的令牌
- javascript - 轴 #0 的数据列不能是字符串类型 Javascript 错误
- python - 在 tflearn 中出现异常:Feed dict 要求输入名为“targets”的变量,但已知不存在此类变量
- r - 如何使用摘要对新计算进行分组?