diff --git a/website/docs/language/tests/index.mdx b/website/docs/language/tests/index.mdx index f34189224aa6..06247570c374 100644 --- a/website/docs/language/tests/index.mdx +++ b/website/docs/language/tests/index.mdx @@ -99,7 +99,7 @@ The `command` attribute states whether the operation should be a [`plan`](/terra The `plan_options` block allows test authors to customize the [planning mode](/terraform/cli/commands/plan#planning-modes) and [options](/terraform/cli/commands/plan#planning-options) they would typically need to edit via command-line flags and options. We cover the `-var` and `-var-file` options in the [Variables](#variables) section. -The `state_key` allows for fine-grained control over which internal state file should be used for a given run block. This is discussed in more detail within [Modules State](#modules-state). +The `state_key` allows for fine-grained control over which internal state file Terraform uses for a given run block. Refer to [Modules State](#modules-state) for more information. ### Assertions @@ -577,11 +577,11 @@ run "verify" { ### Modules state -While Terraform executes a `terraform test` command, Terraform maintains at least one, but possibly many, state files within memory for each test file. Each internal state file is assigned a state key that Terraform uses internally to track the state file. The state key is a unique identifier for the state file and can be overridden by the `state_key` attribute of a `run` block. +While Terraform executes a `terraform test` command, Terraform maintains at least one, but possibly many, state files within memory for each test file. Terraform assigns each internal state file a state key that it uses internally to track the state file. The state key is a unique identifier for the state file and you can override it with the `state_key` attribute of a `run` block. There is always at least one state file that maintains the state of the main configuration under test. This state file is shared by all `run` blocks that do not have a `module` block specifying an alternate module to load. By default, there is also one state file per alternate module that Terraform loads. An alternate module state file is shared by all `run` blocks that execute the given module. -The `state_key` attribute can override this default behavior, and force Terraform to use a specific state file for a given `run` block. This is useful when you want to share state between `run` blocks that do not reference the same module. The default state key is the `module` block's `source` attribute, or the empty string (`""`) if no alternate module is specified. +You can override this default behavior with the `state_key` attribute and force Terraform to use a specific state file for a given `run` block. This is useful when you want to share state between `run` blocks that do not reference the same module. The default state key is the `module` block's `source` attribute, or the empty string (`""`) if no alternate module is specified. The following example uses comments to explain where the state files for each `run` block originate using the default behavior. In the below example Terraform creates and manages a total of three state files. The first state file is for the main configuration under test, the second for the setup module, and the third for the loader module.