Merge pull request #9576 from hashicorp/b-ignore-changes-interp

config: ignore_changes cannot have interpolations
This commit is contained in:
Mitchell Hashimoto 2016-10-25 07:25:52 -07:00 committed by GitHub
commit 9e30c45f1e
3 changed files with 28 additions and 0 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -0,0 +1,7 @@
variable "foo" {}
resource aws_instance "web" {
lifecycle {
ignore_changes = ["${var.foo}"]
}
}