config: depends on cannot contain interpolations [GH-985]
This commit is contained in:
parent
ed115f495b
commit
0e7b150c5b
|
@ -379,6 +379,17 @@ func (c *Config) Validate() error {
|
||||||
|
|
||||||
// Verify depends on points to resources that all exist
|
// Verify depends on points to resources that all exist
|
||||||
for _, d := range r.DependsOn {
|
for _, d := range r.DependsOn {
|
||||||
|
// Check if we contain interpolations
|
||||||
|
rc, err := NewRawConfig(map[string]interface{}{
|
||||||
|
"value": d,
|
||||||
|
})
|
||||||
|
if err == nil && len(rc.Variables) > 0 {
|
||||||
|
errs = append(errs, fmt.Errorf(
|
||||||
|
"%s: depends on value cannot contain interpolations: %s",
|
||||||
|
n, d))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := resources[d]; !ok {
|
if _, ok := resources[d]; !ok {
|
||||||
errs = append(errs, fmt.Errorf(
|
errs = append(errs, fmt.Errorf(
|
||||||
"%s: resource depends on non-existent resource '%s'",
|
"%s: resource depends on non-existent resource '%s'",
|
||||||
|
|
|
@ -109,6 +109,13 @@ func TestConfigValidate_countVarInvalid(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfigValidate_dependsOnVar(t *testing.T) {
|
||||||
|
c := testConfig(t, "validate-depends-on-var")
|
||||||
|
if err := c.Validate(); err == nil {
|
||||||
|
t.Fatal("should not be valid")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestConfigValidate_dupModule(t *testing.T) {
|
func TestConfigValidate_dupModule(t *testing.T) {
|
||||||
c := testConfig(t, "validate-dup-module")
|
c := testConfig(t, "validate-dup-module")
|
||||||
if err := c.Validate(); err == nil {
|
if err := c.Validate(); err == nil {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
variable "foo" {
|
||||||
|
description = "bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource aws_instance "web" {
|
||||||
|
depends_on = ["${var.foo}"]
|
||||||
|
}
|
Loading…
Reference in New Issue