From 8ed7802bbb3bfcc16d06841c0ee0992ca5833dab Mon Sep 17 00:00:00 2001 From: Bradley <41597815+userbradley@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:25:07 +0100 Subject: [PATCH] terraform parralelism flag --- .../terraform/terraform-refresh-takes-ages.md | 35 +++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 36 insertions(+) create mode 100644 docs/automation/iac/terraform/terraform-refresh-takes-ages.md diff --git a/docs/automation/iac/terraform/terraform-refresh-takes-ages.md b/docs/automation/iac/terraform/terraform-refresh-takes-ages.md new file mode 100644 index 00000000..95f91f8c --- /dev/null +++ b/docs/automation/iac/terraform/terraform-refresh-takes-ages.md @@ -0,0 +1,35 @@ +--- +title: Terraform refresh takes ages +--- + +## What + +This can happen with both Terraform and Terragrunt, so this applies to al + +The issue is when running a `terraform plan` the plan will sit at the below for ages + +```text +... +google_folder.sandbox: Refreshing state... [id=folders/<>] +... +^CStopping operation... +``` + +This happens because terraform sucks at walking the graph + +## Solution + +Set the [`parallelism` flag to 20](https://developer.hashicorp.com/terraform/cli/commands/apply#parallelism-n) and disable a refresh + + +=== "Terraform" + + ```shell + terraform plan -parallelism=20 -refresh=false + ``` + +=== "Terragrunt" + + ```shell + terragrunt plan -parallelism=20 -refresh=false + ``` diff --git a/mkdocs.yml b/mkdocs.yml index 8caf5d5e..9afab0d0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -15,6 +15,7 @@ nav: - Remote Data: automation/iac/terraform/remote-data.md - Terraform lock file update: automation/iac/terraform/terraform-lock-file-update.md - "Terraform plugin Cannot locate module locally, unknown reason": automation/iac/terraform/terraform-plugin-cannot-locate-module-locally-unknown-reason.md + - Terraform refresh takes ages: automation/iac/terraform/terraform-refresh-takes-ages.md - Terraform Sleep: automation/iac/terraform/terraform-sleep.md - Terraform verbose: automation/iac/terraform/terraform-verbose.md - tfupdate: automation/iac/terraform/tfupdate.md