From 230658f2b2b1703c2e818a3c21b7d33368826a0c Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Fri, 19 Feb 2021 10:19:27 -0500 Subject: [PATCH] Upgrade ignore_changes wildcard from warning to error The syntax ignore_changes = ["*"] was deprecated and now errors. Use = all instead. --- configs/resource.go | 6 +++--- configs/testdata/error-files/ignore_changes.tf | 5 +++++ configs/testdata/warning-files/ignore_changes.tf | 11 ----------- terraform/context_apply_test.go | 4 ++-- .../main.tf | 2 +- 5 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 configs/testdata/error-files/ignore_changes.tf delete mode 100644 configs/testdata/warning-files/ignore_changes.tf rename terraform/testdata/{apply-ignore-changes-wildcard => apply-ignore-changes-all}/main.tf (74%) diff --git a/configs/resource.go b/configs/resource.go index a6946854d..ae91703bf 100644 --- a/configs/resource.go +++ b/configs/resource.go @@ -211,9 +211,9 @@ func decodeResourceBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) { r.Managed.IgnoreAllChanges = true ignoreAllRange = expr.Range() diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagWarning, - Summary: "Deprecated ignore_changes wildcard", - Detail: "The [\"*\"] form of ignore_changes wildcard is deprecated. Use \"ignore_changes = all\" to ignore changes to all attributes.", + Severity: hcl.DiagError, + Summary: "Invalid ignore_changes wildcard", + Detail: "The [\"*\"] form of ignore_changes wildcard is was deprecated and is now invalid. Use \"ignore_changes = all\" to ignore changes to all attributes.", Subject: attr.Expr.Range().Ptr(), }) continue diff --git a/configs/testdata/error-files/ignore_changes.tf b/configs/testdata/error-files/ignore_changes.tf new file mode 100644 index 000000000..061209c19 --- /dev/null +++ b/configs/testdata/error-files/ignore_changes.tf @@ -0,0 +1,5 @@ +resource "null_resource" "all" { + lifecycle { + ignore_changes = ["*"] # ERROR: Invalid ignore_changes wildcard + } +} diff --git a/configs/testdata/warning-files/ignore_changes.tf b/configs/testdata/warning-files/ignore_changes.tf deleted file mode 100644 index 5678fe7bd..000000000 --- a/configs/testdata/warning-files/ignore_changes.tf +++ /dev/null @@ -1,11 +0,0 @@ -resource "null_resource" "one" { - lifecycle { - ignore_changes = ["triggers"] # WARNING: Quoted references are deprecated - } -} - -resource "null_resource" "all" { - lifecycle { - ignore_changes = ["*"] # WARNING: Deprecated ignore_changes wildcard - } -} diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 96e050805..00468c4bb 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -8372,8 +8372,8 @@ func TestContext2Apply_ignoreChangesWithDep(t *testing.T) { } } -func TestContext2Apply_ignoreChangesWildcard(t *testing.T) { - m := testModule(t, "apply-ignore-changes-wildcard") +func TestContext2Apply_ignoreChangesAll(t *testing.T) { + m := testModule(t, "apply-ignore-changes-all") p := testProvider("aws") p.PlanResourceChangeFn = testDiffFn p.ApplyResourceChangeFn = testApplyFn diff --git a/terraform/testdata/apply-ignore-changes-wildcard/main.tf b/terraform/testdata/apply-ignore-changes-all/main.tf similarity index 74% rename from terraform/testdata/apply-ignore-changes-wildcard/main.tf rename to terraform/testdata/apply-ignore-changes-all/main.tf index a2bc76fde..a89889a09 100644 --- a/terraform/testdata/apply-ignore-changes-wildcard/main.tf +++ b/terraform/testdata/apply-ignore-changes-all/main.tf @@ -2,6 +2,6 @@ resource "aws_instance" "foo" { required_field = "set" lifecycle { - ignore_changes = ["*"] + ignore_changes = all } }