From 56d0f9af9a19215924cf55952af77e6c12521aeb Mon Sep 17 00:00:00 2001 From: rtizzy Date: Fri, 17 Jan 2025 12:49:24 +0100 Subject: [PATCH 1/5] Add section documenting usage and requirements for terragrunt --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 736889c..3ce26a2 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,38 @@ If you want to use OpenTofu, a community fork of Terraform, you need to set the The minimum required version is OpenTofu v1.6 or higher. +### Terragrunt + +#### Without dynamic state + +If you are not leveraging `terragrunt`s [dynamic state generations](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) the environment variable `TF_MIGRATE_EXEC_PATH` must be set to `terragrunt`. + +```shell +# As part of the command or via exporting the variable to your shell. +TFMIGRATE_EXEC_PATH=terragrunt tfmigrate $OTHEROPTIONS +``` + +#### With dynamic state + +If you are leveraging `terragrunt`s [dynamic state generations](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) you must utilize a `generate` block within the `remote_state` block to ensure that `terragrunt` doesn't utilize command line flags for remote state configuration that are incompatible with the local backend, which is utilized by `tfmigrate` for planning. + +``` +remote_state { + backend = "s3" + + config = { + bucket = "highway-terraform-state" + # Other config here + } + # This ensures that a file instead of command line flags are used. + # allowing tfmigrate to work as expected. + generate = { + path = "backend.tf" + if_exists = "overwrite_terragrunt" + } +} +``` + ## Getting Started As you know, terraform state operations are dangerous if you don't understand what you are actually doing. If I were you, I wouldn't use a new tool in production from the start. So, we recommend you to play an example sandbox environment first, which is safe to run terraform state command without any credentials. The sandbox environment mocks the AWS API with `localstack` and doesn't actually create any resources. So you can safely run the `tfmigrate` and `terraform` commands, and easily understand how the tfmigrate works. From b8fb0b89f3f5d675d50b69283047d52ae69ae826 Mon Sep 17 00:00:00 2001 From: rtizzy Date: Fri, 17 Jan 2025 12:53:13 +0100 Subject: [PATCH 2/5] Change wording --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ce26a2..5079368 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ The minimum required version is OpenTofu v1.6 or higher. #### Without dynamic state -If you are not leveraging `terragrunt`s [dynamic state generations](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) the environment variable `TF_MIGRATE_EXEC_PATH` must be set to `terragrunt`. +If you are not leveraging `terragrunt`s [dynamic state generation](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) the environment variable `TF_MIGRATE_EXEC_PATH` must be set to `terragrunt`. ```shell # As part of the command or via exporting the variable to your shell. @@ -107,7 +107,9 @@ TFMIGRATE_EXEC_PATH=terragrunt tfmigrate $OTHEROPTIONS #### With dynamic state -If you are leveraging `terragrunt`s [dynamic state generations](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) you must utilize a `generate` block within the `remote_state` block to ensure that `terragrunt` doesn't utilize command line flags for remote state configuration that are incompatible with the local backend, which is utilized by `tfmigrate` for planning. +If you are leveraging `terragrunt`s [dynamic state generation](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state), the `remote_state` block must include a `generate` block. + +This ensures that that `terragrunt` doesn't utilize command line flags for remote state configuration that are incompatible with the local backend, which is utilized by `tfmigrate` for planning. ``` remote_state { From f4ebf5448c3ef7ea4787d8351f5dbf384a48a8a2 Mon Sep 17 00:00:00 2001 From: Robert Tisdale Date: Mon, 20 Jan 2025 10:32:20 +0100 Subject: [PATCH 3/5] Update README.md Co-authored-by: Masayuki Morita --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5079368..9bf509f 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ If you are leveraging `terragrunt`s [dynamic state generation](https://terragrun This ensures that that `terragrunt` doesn't utilize command line flags for remote state configuration that are incompatible with the local backend, which is utilized by `tfmigrate` for planning. -``` +```hcl remote_state { backend = "s3" From d877a56ac6d14009b7f09d9bbe6b025152c16835 Mon Sep 17 00:00:00 2001 From: Robert Tisdale Date: Mon, 20 Jan 2025 10:32:56 +0100 Subject: [PATCH 4/5] Update README.md Co-authored-by: Masayuki Morita --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9bf509f..9fbdcc8 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ The minimum required version is OpenTofu v1.6 or higher. #### Without dynamic state -If you are not leveraging `terragrunt`s [dynamic state generation](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) the environment variable `TF_MIGRATE_EXEC_PATH` must be set to `terragrunt`. +If you are not leveraging terragrunt's [dynamic state generation](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state) the environment variable `TF_MIGRATE_EXEC_PATH` must be set to `terragrunt`. ```shell # As part of the command or via exporting the variable to your shell. From ee0738a7b456eee646181dc46e07642f1ce3d3db Mon Sep 17 00:00:00 2001 From: Robert Tisdale Date: Mon, 20 Jan 2025 10:33:27 +0100 Subject: [PATCH 5/5] Update README.md Co-authored-by: Masayuki Morita --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 9fbdcc8..afe0186 100644 --- a/README.md +++ b/README.md @@ -107,9 +107,7 @@ TFMIGRATE_EXEC_PATH=terragrunt tfmigrate $OTHEROPTIONS #### With dynamic state -If you are leveraging `terragrunt`s [dynamic state generation](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state), the `remote_state` block must include a `generate` block. - -This ensures that that `terragrunt` doesn't utilize command line flags for remote state configuration that are incompatible with the local backend, which is utilized by `tfmigrate` for planning. +As tfmigrate uses the local backend for planning, some command line flags for the remote state backend cannot be used. If you are leveraging terragrunt's [dynamic state generation](https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#remote_state), the `remote_state` block must include a `generate` block.``` ```hcl remote_state {