terraform - 如何传递列表作为参数?

标签 terraform

此解决方案here不适合我。

// my tf file:
variable "myvar" {type = "list"}

module "my-module" {
  blah = "${var.myvar}"
  source = "path/to/module"
}

各种命令行尝试:

terraform plan -var myvar="zzzz"
should be type list, got string

terraform plan -var myvar=["zzzz"]
invalid value "myvar=[zzzz]" for flag -var: Cannot parse value for variable ("[zzzz]") as valid HCL: At 1:6: unexpected token while parsing list: IDENT

terraform plan -var 'myvar=["zzzz"]'
invalid value "myvar=[zzzz]" for flag -var: Cannot parse value for variable ("[zzzz]") as valid HCL: At 1:6: unexpected token while parsing list: IDENT

最佳答案

奇怪。

我使用了以下main.tf

variable "test" {
    type = "list"
}

并运行:

$ terraform version
Terraform v0.11.1

$ terraform plan -var 'test=["vvv"]'

成功完成。

您的文件/模块中的其他位置可能存在不正确的IDENT。请尝试运行以下命令来验证除未设置变量之外的所有内容:

$ terraform validate -check-variables=false

关于terraform - 如何传递列表作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48086957/

相关文章:

google-cloud-platform - GCP 上的 Terraform 共享 VPC - 静态内部 IP 地址

google-cloud-platform - (Terraform、云运行)错误 : Forbidden Your client does not have permission to get URL/from this server

azure - 如何在Azure azurerm_virtual_network_gateway资源中设置 "bgp_settings" block ?

azure - 无法使用 terraform 更改 azure 子网

azure - Terraform Cloud 无法在 Azure 中国订阅中部署资源

terraform - Terraform 社区提供者是否被视为第三方?

azure - 如何使用Terraform for_each资源 block 并对资源 block 进行计数

amazon-web-services - 是否有适用于 AWS Personalize 的 Terraform 或完成该任务的方法?

amazon-web-services - Cognito 登录的 Lambda 函数第一次不起作用

amazon-web-services - terraform中aws_iam_user_login_profile的PGP key