config: count can't interpolate count variables
This commit is contained in:
parent
8756d52124
commit
bc26777963
|
@ -258,6 +258,11 @@ func (c *Config) Validate() error {
|
|||
// Verify count variables
|
||||
for _, v := range r.RawCount.Variables {
|
||||
switch v.(type) {
|
||||
case *CountVariable:
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"%s: resource count can't reference count variable: %s",
|
||||
n,
|
||||
v.FullKey()))
|
||||
case *ModuleVariable:
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"%s: resource count can't reference module variable: %s",
|
||||
|
|
|
@ -60,6 +60,13 @@ func TestConfigValidate_countInt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_countCountVar(t *testing.T) {
|
||||
c := testConfig(t, "validate-count-count-var")
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("should not be valid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_countModuleVar(t *testing.T) {
|
||||
c := testConfig(t, "validate-count-module-var")
|
||||
if err := c.Validate(); err == nil {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
resource "aws_instance" "web" {
|
||||
count = "${count.index}"
|
||||
}
|
Loading…
Reference in New Issue