terragrunt-v19-upgrade
This is a tool to upgrade Terragrunt configurations from version <= 0.18 to version 0.19 according to the upgrade guide. It also attempts to upgrade the configuration syntax from HCL1 to HCL2.
Warnings / Known Issues / Limitations
This tool should be used with some caution. By default, its behavior is destructive: When upgrading a v0.18 configuration (terraform.tfvars
), the new configuration will be "validated" by parsing it with the HCL2 parser. If no errors are returned, the new configuration will be formatted and written to disk in a new file (terragrunt.hcl
), and the old file will be deleted. This should be used with a VCS (or, take a backup first. But seriously, just use git).
This tool does not try to be as comprehensive as the terraform 0.12upgrade
tool. This should be ok, since the scope of this is much narrower. We're only concerned with upgrading tfvars
files, and the syntax of those files is much simpler than normal terraform configuration. However, there are still some limitations:
- Heredoc variables may not be upgraded correctly. If you have heredoc variables in your configuration, check to make sure they were upgraded correctly.
- Whitespace/formatting will not preserved exactly - the upgraded configuration will be formatted with the standard formatter
- Multi-line comments may not be properly indented after upgrading (see below)
- A "line" or "lead" comment on the
terragrunt
block will be lost (see below)
For the most part, comments are preserved - including comments that are not "attached" to a specific node in the configuration. The one exception to this is a comment on the terragrunt
block:
// this comment will be lost
terragrunt = { // this comment will also be lost
// this will be preserved
// this "detached" comment will also be preserved
// this will be preserved
include { // as will this
path = "${find_in_parent_folders()}" // and this
}
/*
* This comment may not be formatted correctly, but it will be preserved
*/
remote_state {
// ...
}
}
// comments on variables will be preserved as well
Usage
$ terragrunt-v19-upgrade
usage: terragrunt-v19-upgrade [flags] [file|dir ...]
terragrunt-v19-upgrade - A tool for upgrading terragrunt configs from terragrunt <= v0.18 to >= v0.19.
Usage: terragrunt-v19-upgrade <command>
Flags:
-d, --dry-run Do not update any files, just print changes to stdout (default: false)
-k, --keep Keep old terraform.tfvars files (default: false)
-m, --git-mv Update files in place and "git mv terraform.tfvars terragrunt.hcl" (default: false)
-r, --recursive Search subdirectores for terraform.tfvars files (default: false)
Commands:
version Show the version information.
To upgrade a single file, run:
$ terragrunt-v19-upgrade terraform.tfvars
Multiple paths can be specified:
$ terragrunt-v19-upgrade dir1/terraform.tfvars dir2/terraform.tfvars
Or, terragrunt-v19-upgrade
can search for terragrunt configurations recursively:
$ terragrunt-v19-upgrade -r dir/