Skip to content

Commit

Permalink
Merge pull request #9576 from hashicorp/b-ignore-changes-interp
Browse files Browse the repository at this point in the history
config: ignore_changes cannot have interpolations
  • Loading branch information
mitchellh authored Oct 25, 2016
2 parents 323e037 + 694b16d commit 9e30c45
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "foo" {}

resource aws_instance "web" {
lifecycle {
ignore_changes = ["${var.foo}"]
}
}

0 comments on commit 9e30c45

Please sign in to comment.