我在terraform中配置了以下提供程序:
provider "google" {
credentials = "${file("key.json")}"
project = "project-123456"
region = "${var.region}"
}
我能够将项目名称移动到我在调用terraform计划并申请时传入的变量。但凭据密钥文件似乎不可配置。
provider "google" {
credentials = "${var.key}"
project = "${var.project}"
region = "${var.region}"
}
terraform plan -var key =' $ {file(" key.json")}' -var project = project-123456
引发此错误:
- provider.google:凭据无效JSON' $ {file(" key.json")}':无效字符' $'寻找开始 值
我也尝试过这样:
provider "google" {
credentials = "${file(${var.key})}"
project = "${var.project}"
region = "${var.region}"
}
terraform plan -var key = key.json -var project = project-123456
但它引发了这个错误:
读取配置供应商配置时出错google:解析错误为1:8:预期表达但发现无效序列" $"
如何为提供商配置凭证文件?
答案 0 :(得分:1)
credentials =“$ {file($ {var.key})}”
credentials =“$ {file(” $ {var.key} “)}”
terraform plan -var key = key.json -var project = project-123456