config: allow exact multi-resource references outside slices
This commit is contained in:
parent
ecafcfa682
commit
4cb1ea6ae1
|
@ -455,7 +455,7 @@ func (c *Config) validateVarContextFn(
|
|||
return
|
||||
}
|
||||
|
||||
if rv.Multi && loc != reflectwalk.SliceElem {
|
||||
if rv.Multi && rv.Index == -1 && loc != reflectwalk.SliceElem {
|
||||
*errs = append(*errs, fmt.Errorf(
|
||||
"%s: multi-variable must be in a slice", source))
|
||||
}
|
||||
|
|
|
@ -221,6 +221,13 @@ func TestConfigValidate_varDefaultInterpolate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_varMultiExactNonSlice(t *testing.T) {
|
||||
c := testConfig(t, "validate-var-multi-exact-non-slice")
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Fatalf("should be valid: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_varMultiNonSlice(t *testing.T) {
|
||||
c := testConfig(t, "validate-var-multi-non-slice")
|
||||
if err := c.Validate(); err == nil {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
resource "aws_instance" "foo" {
|
||||
count = 3
|
||||
}
|
||||
|
||||
resource "aws_instance" "bar" {
|
||||
foo = "${aws_instance.foo.0.id}"
|
||||
}
|
Loading…
Reference in New Issue