config: count can't interpolate count variables

This commit is contained in:
Mitchell Hashimoto 2014-10-02 18:22:32 -07:00
parent 8756d52124
commit bc26777963
3 changed files with 15 additions and 0 deletions

View File

@ -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",

View File

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

View File

@ -0,0 +1,3 @@
resource "aws_instance" "web" {
count = "${count.index}"
}