很可能我做错了什么或在这里遗漏了一些东西。
这就是我的 terraform 模板的样子:
locals {
credentials_file_path = "~/gcp-auth/account.json"
}
terraform {
backend "gcs" {
bucket = "somebucket-tf-state"
prefix = "terraform/state/"
credentials = "~/gcp-auth/account.json"
}
}
provider "google" {
region = "${var.region}"
credentials = "${file(local.credentials_file_path)}"
}
module "project" {
source = "../modules/gcp-project/"
project_name = "${var.project_name}"
billing_account = "${var.billing_account}"
org_id = "${var.org_id}"
}
当我使用不同的参数多次运行它时,它会覆盖以前的状态文件。
这是我在桶中看到的:
Buckets/somebucket-tf-state/terraform/state/default.tfstate
有没有办法可以为每个运行模板的项目创建不同的状态文件?