From d3a2580fc806d94e4b46e85b12d4ca3c5e6e647c Mon Sep 17 00:00:00 2001 From: Simon Schwichtenberg <33393719+schwichti@users.noreply.github.com> Date: Fri, 23 Jun 2023 09:57:03 +0200 Subject: [PATCH 1/3] Update configuration.mdx More details on how to use `-backend-config` --- .../settings/backends/configuration.mdx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/website/docs/language/settings/backends/configuration.mdx b/website/docs/language/settings/backends/configuration.mdx index 321392674b..228bcb2a8c 100644 --- a/website/docs/language/settings/backends/configuration.mdx +++ b/website/docs/language/settings/backends/configuration.mdx @@ -104,7 +104,32 @@ There are several ways to supply the remaining arguments: - **File**: A configuration file may be specified via the `init` command line. To specify a file, use the `-backend-config=PATH` option when running - `terraform init`. If the file contains secrets it may be kept in + `terraform init`. You need an existing backend configuration that you can override with + the config file you provide in PATH. The config file must contain only the key/value pairs + for your backend. For example, run `terraform init -backend-config="./state.config"` to + override your backend configuration defined in `state.tf` with the values from `state.config`: + + ```hcl + # state.tf + terraform { + backend "s3" { + bucket = "" + key = "" + region = "" + profile= "" + } + } + ``` + + ```hcl + # state.config + bucket = "your-bucket" + key = "your-state.tfstate" + region = "eu-central-1" + profile= "Your_Profile" + ``` + + Important: If your config file contains secrets it may be kept in a secure data store, such as [Vault](https://www.vaultproject.io/), in which case it must be downloaded to the local disk before running Terraform. From bc989f64309719533529476c9a6b3904d5714f56 Mon Sep 17 00:00:00 2001 From: Craig Wright Date: Thu, 25 Jul 2024 15:46:18 -0700 Subject: [PATCH 2/3] Update website/docs/language/settings/backends/configuration.mdx Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> --- website/docs/language/settings/backends/configuration.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/language/settings/backends/configuration.mdx b/website/docs/language/settings/backends/configuration.mdx index 228bcb2a8c..bf2f785620 100644 --- a/website/docs/language/settings/backends/configuration.mdx +++ b/website/docs/language/settings/backends/configuration.mdx @@ -104,10 +104,10 @@ There are several ways to supply the remaining arguments: - **File**: A configuration file may be specified via the `init` command line. To specify a file, use the `-backend-config=PATH` option when running - `terraform init`. You need an existing backend configuration that you can override with - the config file you provide in PATH. The config file must contain only the key/value pairs - for your backend. For example, run `terraform init -backend-config="./state.config"` to - override your backend configuration defined in `state.tf` with the values from `state.config`: + `terraform init`. The partial configuration must have a `backend` block containing keys set to empty values. When you run the `terraform init -backend-config=""` command, Terraform populates the keys in the partial `backend` configuration with matching key values from the specified configuration file. In the following example, the keys defined in the `backend` block of the `state.tf` configuration file are populated with values from the `state.config` configuration: + ``` + $ `terraform init -backend-config="./state.config"` + ``` ```hcl # state.tf From f6c4fb6e7fa01c3cd11e14d8904286d148ef010d Mon Sep 17 00:00:00 2001 From: Craig Wright Date: Thu, 25 Jul 2024 15:46:24 -0700 Subject: [PATCH 3/3] Update website/docs/language/settings/backends/configuration.mdx Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> --- website/docs/language/settings/backends/configuration.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/language/settings/backends/configuration.mdx b/website/docs/language/settings/backends/configuration.mdx index bf2f785620..65fffeb9d3 100644 --- a/website/docs/language/settings/backends/configuration.mdx +++ b/website/docs/language/settings/backends/configuration.mdx @@ -129,7 +129,7 @@ There are several ways to supply the remaining arguments: profile= "Your_Profile" ``` - Important: If your config file contains secrets it may be kept in + When your configuration file contains secrets, you can store them in a secure data store, such as [Vault](https://www.vaultproject.io/), in which case it must be downloaded to the local disk before running Terraform.