我创建了这些文件:
变量.tf
variable gcp_project {
type = string
}
主文件
resource "google_secret_manager_secret" "my_password" {
provider = google-beta
secret_id = "my-password"
replication {
automatic = true
}
}
data "google_secret_manager_secret_version" "my_password_v1" {
provider = google-beta
project = var.gcp_project
secret = google_secret_manager_secret.my_password.secret_id
version = 1
}
输出.tf
output my_password_version {
value = data.google_secret_manager_secret_version.my_password_v1.version
}
应用时出现错误:
Error: Error retrieving available secret manager secret versions: googleapi: Error 404: Secret Version [projects/2381824501/secrets/my-password/versions/1] not found.
所以我通过 gcloud cli 创建了这个秘密:
echo -n "my_secret_password" | gcloud secrets create "my-password" \
--data-file - \
--replication-policy "automatic"
然后再次应用 terraform,它说Error: project: required field is not set
。
如果使用 terraform 创建具有真实价值的秘密,怎么办?