我想要一个资源块,它可以循环我用变量块定义的每个变量。这可能吗?
例如:假设我在 tfvar 文件中设置 myfirstvar 和 mysecondvar。我正在寻找一种解决方案,该解决方案将采用以下模板并将所有名称、值和描述部署到 Terraform Cloud。
variable "myfirstvar" {
type = string
description = "a var to upload"
}
variable "mysecondvar" {
type = string
description = "another var to upload"
}
resource "tfe_variable" "test" {
for_each = var
key = currentvar.key
value = currentvar.value
category = "terraform"
workspace_id = tfe_workspace.test.id
description = currentvar.description
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我能想到的唯一解决方案是将所有 tfvar 放入单个列表类型变量中,但这不会有来自变量块的附加信息。或者我可以在另一个程序中对变量块进行进一步解析,并且 tfvars 文件收集所有必要的信息。两者都不理想。
terraform ×1