Back to Terragrunt

Dependency Fetch Output From State

docs/src/data/flags/dependency-fetch-output-from-state.mdx

1.1.43.0 KB
Original Source

import { Aside } from '@astrojs/starlight/components'; import Before from '@components/Before.astro'; import Since from '@components/Since.astro';

This flag modifies how Terragrunt retrieves output values from dependent units. When enabled, Terragrunt will read the outputs directly from the state file instead of running tofu output or terraform output.

<Aside type="note"> This flag is equivalent to enabling the `dependency-fetch-output-from-state` experiment. You can also enable this feature using `--experiment dependency-fetch-output-from-state` or `--experiment-mode`. For more information, see the [Experiments documentation](/reference/experiments/active#dependency-fetch-output-from-state). </Aside>

The main benefit this flag provides is performance. Reading directly from state is typically faster than executing the OpenTofu/Terraform binary to get the same outputs.

<Before version="1.1.4"> This approach is only supported by the S3 backend. </Before> <Since version="1.1.4"> This approach supports S3 and GCS backends. It also supports the Azure Storage (`azurerm`) backend when the [`azure-backend`](/reference/experiments/active#azure-backend) experiment is enabled. Other backends continue to use `tofu output` or `terraform output`.

Terragrunt also uses the native output path for Azure state protected by customer_provided_key, Azure configurations requiring native-only authentication or endpoint behavior, and GCS configurations whose backend-specific credential or endpoint behavior is not yet mirrored by the direct reader. </Since>

OpenTofu/Terraform may change the schema of the state file in the future, breaking this functionality.

<Aside type="caution"> This flag is **not compatible with OpenTofu state encryption**. When OpenTofu's client-side state encryption is enabled, the state file is encrypted before upload. Since this flag causes Terragrunt to read the raw state object directly through the backend's cloud storage API, it cannot decrypt the state and will fail with a JSON parsing error. If you are using OpenTofu state encryption, disable this flag with `--no-dependency-fetch-output-from-state`. </Aside> <Aside type="caution"> Avoid using this flag without pinning the version of OpenTofu/Terraform you are using.

There is no guarantee that OpenTofu/Terraform will maintain the existing schema of their state files, so there is also no guarantee that the flag will work as expected in future versions of OpenTofu/Terraform. They have not changed the schema of the state file in a long time, but there is no guarantee that they will not change it in the future. We are coordinating with the OpenTofu team to encourage stability in the state file schema, unless significant performance improvements can be made to OpenTofu output fetching to make this flag unnecessary.

</Aside> <Aside type="tip"> Direct output fetching is a performance optimization. For more details on performance optimizations, their tradeoffs, and other performance tips, read the dedicated [Performance documentation](/troubleshooting/performance). </Aside>