Notes: Terragrunt

DISCLAIMER: this is not meant to be coherent post. Sorry. Just notes for future reference. There will probably be some future updates here.

Terragrunt produces error on terragrunt plan for mocked outputs

If you mocked outputs in your terragrunt configuration, you might get an error when running terragrunt plan when the output of a dependency have not been yet applied. This can be dealt with by refreshing the state of the dependency:

# example terragrunt.hcl file

terraform {
  source = "some-module"
}

dependency "vpc" {
  config_path = "../vpc"
  mock_outputs = {
    vpc_name = "my-vpc" # not yet applied
  }
  mock_outputs_allowed_terraform_commands = ["plan", "apply"]
}

inputs = {
  vpc_id = dependency.vpc.outputs.vpc_name
}

This could produce an error like:

16:58:28.341 ERROR  ./terragrunt.hcl: Unsupported attribute; This object does not have an attribute named "vpc_name"., and 1 other diagnostic(s)
16:58:28.341 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

To fix this, you can refresh the state of the dependency:

terragrunt refresh

WARNING! This article has been written a long time ago. It may no longer represent the current views of the author!


Consider commenting via e-mail

Newest in technical