terragrunt always re-runs `terraform init` with terraform 0.14.0-rc1

Created on 13 Nov 2020  路  8Comments  路  Source: gruntwork-io/terragrunt

It seems terragrunt fails to detect when initialization is not necessary when using terraform 0.14.0-rc1. It always runs terraform init no matter what, and it takes a lot of time especially when dependencies are involved.

I also tried terragrunt apply --terragrunt-no-auto-init, and here's what happens:

$ terragrunt apply --terragrunt-no-auto-init
...
[terragrunt] 2020/11/13 01:29:18 Cannot continue because init is needed, but Auto-Init is disabled.  You must run 'terragrunt init' manually.
[terragrunt] 2020/11/13 01:29:18 Unable to determine underlying exit code, so Terragrunt will exit with error code 1
enhancement help wanted

Most helpful comment

A temporary workaround for this issue is to create a empty folder plugins in
.terragrunt-cache/RANDOM_HASH/ANOTHER_RANDOM_HASH/.terraform/
like
mkdir .terragrunt-cache/X0em602TiSrcCnD8MSB9SfZ-Wiw/Dtif5ds3Xi5dZzANQWFL-b_aEkQ/.terraform/plugins

Terragrunt stops reinit after created this empty folder.

A way to automate it is add an after hook.

terraform {
  after_hook "reinit_workaround" {
    commands = ["plan", "apply"]
    execute = ["ruby", "-rfileutils", "-e", "FileUtils.mkdir_p(\".terraform/plugins\")"]
  }
}

All 8 comments

This is the problem: https://github.com/gruntwork-io/terragrunt/blob/7f0920ab4b961984a8d1cb60af48a2bb00961ad9/cli/cli_app.go#L723

It seems that terraform renamed .terraform/plugins into .terraform/providers. So the check needs to be:

        providersPath013 := util.JoinPath(terragruntOptions.DataDir(), "plugins")
    providersPath014 := util.JoinPath(terragruntOptions.DataDir(), "providers")
    return !(util.FileExists(providersPath013) || util.FileExists(providersPath014))

Thanks for reporting! Since 0.14.0 is not out yet, we have not yet tested or updated Terragrunt to work with it. We will do so once the final version is released.

Now that 0.14 is out I think this must be locked at

Ah, good point, thanks for the reminder!

Also just ran into this myself 馃槃

Facing the same issue

A temporary workaround for this issue is to create a empty folder plugins in
.terragrunt-cache/RANDOM_HASH/ANOTHER_RANDOM_HASH/.terraform/
like
mkdir .terragrunt-cache/X0em602TiSrcCnD8MSB9SfZ-Wiw/Dtif5ds3Xi5dZzANQWFL-b_aEkQ/.terraform/plugins

Terragrunt stops reinit after created this empty folder.

A way to automate it is add an after hook.

terraform {
  after_hook "reinit_workaround" {
    commands = ["plan", "apply"]
    execute = ["ruby", "-rfileutils", "-e", "FileUtils.mkdir_p(\".terraform/plugins\")"]
  }
}

@johnlinvc thanks your workaround makes it a lot more usable was so slow before

Was this page helpful?
0 / 5 - 0 ratings