diff --git a/config/config.go b/config/config.go index da2186b37..3c8f8826d 100644 --- a/config/config.go +++ b/config/config.go @@ -579,6 +579,20 @@ func (c *Config) Validate() error { "together with a wildcard: %s", n, v)) } } + + // Verify ignore_changes has no interpolations + rc, err := NewRawConfig(map[string]interface{}{ + "root": r.Lifecycle.IgnoreChanges, + }) + if err != nil { + errs = append(errs, fmt.Errorf( + "%s: lifecycle ignore_changes error: %s", + n, err)) + } else if len(rc.Interpolations) > 0 { + errs = append(errs, fmt.Errorf( + "%s: lifecycle ignore_changes cannot contain interpolations", + n)) + } } for source, vs := range vars { diff --git a/config/config_test.go b/config/config_test.go index 201a62893..7c7776b94 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -265,6 +265,13 @@ func TestConfigValidate_ignoreChangesBad(t *testing.T) { } } +func TestConfigValidate_ignoreChangesInterpolate(t *testing.T) { + c := testConfig(t, "validate-ignore-changes-interpolate") + if err := c.Validate(); err == nil { + t.Fatal("should not be valid") + } +} + func TestConfigValidate_moduleNameBad(t *testing.T) { c := testConfig(t, "validate-module-name-bad") if err := c.Validate(); err == nil { diff --git a/config/test-fixtures/validate-ignore-changes-interpolate/main.tf b/config/test-fixtures/validate-ignore-changes-interpolate/main.tf new file mode 100644 index 000000000..e3b5a87f4 --- /dev/null +++ b/config/test-fixtures/validate-ignore-changes-interpolate/main.tf @@ -0,0 +1,7 @@ +variable "foo" {} + +resource aws_instance "web" { + lifecycle { + ignore_changes = ["${var.foo}"] + } +}