【发布时间】:2022-05-05 23:33:42
【问题描述】:
我在variables.tf 中声明了一个变量,如下所示:
variable "MyAmi" {
type = map(string)
}
但是当我这样做时:
terraform plan -var 'MyAmi=xxxx'
我明白了:
Error: Variables not allowed
on <value for var.MyAmi> line 1:
(source code not available)
Variables may not be used here.
最小代码示例:
test.tf
provider "aws" {
}
# S3
module "my-s3" {
source = "terraform-aws-modules/s3-bucket/aws"
bucket = "${var.MyAmi}-bucket"
}
变量.tf
variable "MyAmi" {
type = map(string)
}
terraform plan -var 'MyAmi=test'
Error: Variables not allowed
on <value for var.MyAmi> line 1:
(source code not available)
Variables may not be used here.
有什么建议吗?
【问题讨论】:
-
你能在minimal reproducible example 中重新创建它,我们可以运行并看到同样的错误吗?看起来您错过了引发错误的位,或者解析器只是在某处的堆中摔倒了。
标签: terraform