terraform-state-mover
terraform-state-mover copied to clipboard
Terragrunt Support
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
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!
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)