From e6382155ea97fd607e2b2f4d27c8413a68483728 Mon Sep 17 00:00:00 2001 From: Danil Zburivsky Date: Wed, 17 Feb 2021 15:24:33 -0400 Subject: [PATCH] Make sure Terragrunt commands can be configured with -lock=true --- modules/terraform/apply.go | 2 +- modules/terraform/apply_test.go | 18 ++++++++++++++++++ modules/terraform/destroy.go | 2 +- modules/terraform/format.go | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/terraform/apply.go b/modules/terraform/apply.go index 2d5702c8c..330fd80d3 100644 --- a/modules/terraform/apply.go +++ b/modules/terraform/apply.go @@ -60,7 +60,7 @@ func TgApplyAllE(t testing.TestingT, options *Options) (string, error) { return "", TgInvalidBinary(options.TerraformBinary) } - return RunTerraformCommandE(t, options, FormatArgs(options, "apply-all", "-input=false", "-lock=false", "-auto-approve")...) + return RunTerraformCommandE(t, options, FormatArgs(options, "apply-all", "-input=false", "-auto-approve")...) } // ApplyAndIdempotent runs terraform apply with the given options and return stdout/stderr from the apply command. It then runs diff --git a/modules/terraform/apply_test.go b/modules/terraform/apply_test.go index 1e3288bc1..042fedf5e 100644 --- a/modules/terraform/apply_test.go +++ b/modules/terraform/apply_test.go @@ -182,3 +182,21 @@ func TestParallelism(t *testing.T) { duration := end.Sub(start) require.Greater(t, int64(duration.Seconds()), int64(25)) } +func TestTgApplyUseLockNoError(t *testing.T) { + t.Parallel() + + testFolder, err := files.CopyTerragruntFolderToTemp("../../test/fixtures/terragrunt/terragrunt-no-error", t.Name()) + require.NoError(t, err) + + options := WithDefaultRetryableErrors(t, &Options{ + TerraformDir: testFolder, + TerraformBinary: "terragrunt", + Lock: true, + }) + + out := TgApplyAll(t, options) + + require.Contains(t, out, "Hello, World") + // make sure -lock CLI option is passed down correctly + require.Contains(t, out, "-lock=true") +} diff --git a/modules/terraform/destroy.go b/modules/terraform/destroy.go index 05eeb9daa..69f45d1b1 100644 --- a/modules/terraform/destroy.go +++ b/modules/terraform/destroy.go @@ -30,5 +30,5 @@ func TgDestroyAllE(t testing.TestingT, options *Options) (string, error) { return "", TgInvalidBinary(options.TerraformBinary) } - return RunTerraformCommandE(t, options, FormatArgs(options, "destroy-all", "-force", "-input=false", "-lock=false")...) + return RunTerraformCommandE(t, options, FormatArgs(options, "destroy-all", "-force", "-input=false")...) } diff --git a/modules/terraform/format.go b/modules/terraform/format.go index b00a30c14..170707ce7 100644 --- a/modules/terraform/format.go +++ b/modules/terraform/format.go @@ -14,7 +14,9 @@ import ( var TerraformCommandsWithLockSupport = []string{ "plan", "apply", + "apply-all", "destroy", + "destroy-all", "init", "refresh", "taint",