Reputation: 1
I'm running terraform from a GCP compute instance to create projects using https://github.com/terraform-google-modules/terraform-google-project-factory
The definition seems correct--terraform creates a bare state file in the GCS bucket, but then after the apply, terraform has only created a local state file and doesn't update the remote backend statefile.
data "terraform_remote_state" "tfstate-gcp" {
backend = "gcs"
config = {
bucket = "project-provisioning-state-5309"
prefix = "project_${var.project_name}"
}
}
As noted, running terraform init creates the bare backend state file in the correct bucket location:
{
"version": 4,
"terraform_version": "1.4.6",
"serial": 1,
"lineage": "ee20ff2d-f55d-aae0-7c4b-cbxyzxyzxead8",
"outputs": {},
"resources": [],
"check_results": null
}
Running terraform apply, a terraform.tfstate file is created in the local directory, but the backend state file is not updated.
Any ideas what is going sideways?
Upvotes: 0
Views: 549
Reputation: 74604
The configuration you've shown is using the terraform_remote_state
data source to retrieve the output values from another configuration's state.
To specify where to store the state for the current configuration, you will need to write a backend configuration.
Upvotes: 1