From f5a503ff8775aad16a9dcdbc17be7f4f00d225e8 Mon Sep 17 00:00:00 2001 From: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:46:10 -0400 Subject: [PATCH] Add more context about local backend configuration state file --- .../language/settings/backends/configuration.mdx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/website/docs/language/settings/backends/configuration.mdx b/website/docs/language/settings/backends/configuration.mdx index 83c850a819..b0e6928883 100644 --- a/website/docs/language/settings/backends/configuration.mdx +++ b/website/docs/language/settings/backends/configuration.mdx @@ -71,18 +71,20 @@ If a configuration includes no backend block, Terraform defaults to using the `l ## Initialization -Whenever a configuration's backend changes, you must run `terraform init` again +When you change a backend's configuration, you must run `terraform init` again to validate and configure the backend before you can perform any plans, applies, or state operations. -When changing backends, Terraform will give you the option to migrate +After you initialize, Terraform creates `.terraform/terraform.tfstate` locally. This file contains the most recent backend configuration, including any authentication parameters you provided to the Terraform CLI. Do not check `.terraform/terraform.tfstate` into Git, as it may contain sensitive credentials for your remote backend. + +The local backend configuration file is different and entirely separate from the `terraform.tfstate` file that contains [state data](/language/state) about your real-world infrastruture. Terraform stores the `terraform.tfstate` file in your remote backend. + +When you change backends, Terraform gives you the option to migrate your state to the new backend. This lets you adopt backends without losing any existing state. -To be extra careful, we always recommend manually backing up your state -as well. You can do this by simply copying your `terraform.tfstate` file -to another location. The initialization process should create a backup -as well, but it never hurts to be safe! +~> **Important:** Before migrating to a new backend, we strongly recommend manually backing up your state by copying your `terraform.tfstate` file +to another location. ## Partial Configuration