Merge pull request #9576 from hashicorp/b-ignore-changes-interp
config: ignore_changes cannot have interpolations
This commit is contained in:
commit
9e30c45f1e
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
variable "foo" {}
|
||||
|
||||
resource aws_instance "web" {
|
||||
lifecycle {
|
||||
ignore_changes = ["${var.foo}"]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue