terraform-state-mover icon indicating copy to clipboard operation
terraform-state-mover copied to clipboard

Terragrunt Support

Open 40Cakes opened this issue 3 years ago • 2 comments

Hi, I was just wondering if at all, there was a plan or an existing way to read input variables from a gruntwork terragrunt file instead of a tfvars file?

root@c6cacc87b3af:/workdir/environments/poc# terraform-state-mover -- -var-file=terragrunt.hcl

Error: Unexpected "include" block

  on terragrunt.hcl line 1:
   1: include {

Blocks are not allowed here.

exit status 1

40Cakes avatar Jul 20 '21 01:07 40Cakes

I'd also love a terragrunt support - this is my go-to tool for managing terraform and I'd gladly use the tool if it has terragrunt support!

Nicarim avatar Feb 17 '22 15:02 Nicarim

You can use it as-is, all you need is to run terragrunt plan -lock=false --terragrunt-debug | head -n1, and catch terragrunt working directory from the output:

INFO[0000] Debug mode requested: generating debug file terragrunt-debug.tfvars.json in working dir /home/ec2-user/terragrunt/.terragrunt-cache/a/b/c/d

In this example it's /home/ec2-user/terragrunt/.terragrunt-cache/a/b/c/d, so you execute terraform-state-mover from there.

Unfortunately you can't pass -chdir parameter as an extra argument, as it should prepend plan command, so it should be terraform -chdir=/something plan, while the extra arguments we pass after double dashes will be appended. That's why you need to execute it from the working directory:

 (cd /home/ec2-user/terragrunt/.terragrunt-cache/a/b/c/d; terraform-state-mover -v -n -- -var-file=terragrunt-debug.tfvars.json)

caseycs avatar Jun 15 '23 18:06 caseycs