Skip to content
Latchkey

Terragrunt dependency "has not been applied yet" (mock_outputs) in CI

On a fresh stack, run-all plan tries to read a dependency's outputs before that dependency has been applied, so those outputs do not exist yet. Terragrunt errors unless the dependency block provides mock_outputs to use during plan.

What this error means

terragrunt run-all plan fails with "has not been applied yet" or "cannot read outputs" for a dependency, on a stack that has never been applied.

terragrunt
ERRO[0003] Module live/prod/vpc has not been applied yet. Its outputs cannot be read
by live/prod/app during plan. Configure mock_outputs on the dependency block to allow
plan to run before the dependency is applied.

Common causes

Plan runs before the dependency is applied

On a first-time or PR plan, the upstream unit has no state, so its real outputs do not exist for the dependent unit to read.

The dependency block has no mock_outputs

Without mock_outputs, Terragrunt has no placeholder values to feed the plan, so it errors instead of planning.

How to fix it

Provide mock_outputs for plan

  1. Add mock_outputs with placeholder values matching the real output shape.
  2. Restrict them to plan-time with mock_outputs_allowed_terraform_commands.
  3. Re-run run-all plan on the fresh stack.
terragrunt.hcl
dependency "vpc" {
  config_path = "../vpc"
  mock_outputs = { vpc_id = "vpc-00000000" }
  mock_outputs_allowed_terraform_commands = ["plan", "validate"]
}

Apply dependencies first

For a real deploy, apply the upstream units so their outputs exist before dependents plan.

Terminal
terragrunt run-all apply --terragrunt-non-interactive

How to prevent it

  • Add mock_outputs to every dependency read during plan.
  • Scope mocks to plan/validate so real applies never use fake values.
  • Apply base layers first so downstream outputs are real.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →