diff --git a/test/fixtures/exclude/exclude-by-action/exclude-apply/main.tf b/test/fixtures/exclude/exclude-by-action/exclude-apply/main.tf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/exclude/exclude-by-action/exclude-apply/terragrunt.hcl b/test/fixtures/exclude/exclude-by-action/exclude-apply/terragrunt.hcl new file mode 100644 index 0000000000..05678883b6 --- /dev/null +++ b/test/fixtures/exclude/exclude-by-action/exclude-apply/terragrunt.hcl @@ -0,0 +1,5 @@ +exclude { + if = true + actions = ["apply"] + exclude_dependencies = true +} \ No newline at end of file diff --git a/test/fixtures/exclude/exclude-by-action/exclude-plan/main.tf b/test/fixtures/exclude/exclude-by-action/exclude-plan/main.tf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/exclude/exclude-by-action/exclude-plan/terragrunt.hcl b/test/fixtures/exclude/exclude-by-action/exclude-plan/terragrunt.hcl new file mode 100644 index 0000000000..1204dc9383 --- /dev/null +++ b/test/fixtures/exclude/exclude-by-action/exclude-plan/terragrunt.hcl @@ -0,0 +1,5 @@ +exclude { + if = true + actions = ["plan"] + exclude_dependencies = true +} \ No newline at end of file diff --git a/test/integration_exclude_test.go b/test/integration_exclude_test.go index d7ac41ac87..06f8a32f25 100644 --- a/test/integration_exclude_test.go +++ b/test/integration_exclude_test.go @@ -12,6 +12,7 @@ import ( const ( testExcludeByDefault = "fixtures/exclude/exclude-default" testExcludeDisabled = "fixtures/exclude/exclude-disabled" + testExcludeByAction = "fixtures/exclude/exclude-by-action" ) func TestExcludeByDefault(t *testing.T) { @@ -43,3 +44,26 @@ func TestExcludeDisabled(t *testing.T) { assert.Contains(t, stderr, "app1") assert.Contains(t, stderr, "app2") } + +func TestExcludeApply(t *testing.T) { + t.Parallel() + + cleanupTerraformFolder(t, testExcludeByAction) + tmpEnvPath := helpers.CopyEnvironment(t, testExcludeByAction) + rootPath := util.JoinPath(tmpEnvPath, testExcludeByAction) + + _, stderr, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all plan --terragrunt-non-interactive --terragrunt-working-dir "+rootPath) + + require.NoError(t, err) + + assert.Contains(t, stderr, "exclude-apply") + assert.NotContains(t, stderr, "exclude-plan") + + _, stderr, err = helpers.RunTerragruntCommandWithOutput(t, "terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir "+rootPath) + + require.NoError(t, err) + + // should be applied only exclude-plan + assert.Contains(t, stderr, "exclude-plan") + assert.NotContains(t, stderr, "exclude-apply") +}