diff --git a/terraform/interpolate.go b/terraform/interpolate.go index f03154141..870fac762 100644 --- a/terraform/interpolate.go +++ b/terraform/interpolate.go @@ -162,7 +162,6 @@ func (i *Interpolater) valueModuleVar( } else { // Same reasons as the comment above. result[n] = unknownVariable() - } } @@ -485,11 +484,15 @@ func (i *Interpolater) computeResourceMultiVariable( err) } - // If we have no module in the state yet or count, return empty - if module == nil || len(module.Resources) == 0 || count == 0 { + // If count is zero, we return an empty list + if count == 0 { return &ast.Variable{Type: ast.TypeList, Value: []ast.Variable{}}, nil } + // If we have no module in the state yet or count, return unknown + if module == nil || len(module.Resources) == 0 { + return &unknownVariable, nil + } var values []string for j := 0; j < count; j++ { id := fmt.Sprintf("%s.%d", v.ResourceId(), j)