diff --git a/config/hcl2shim/flatmap.go b/config/hcl2shim/flatmap.go index 4d61ba073..2f7954d76 100644 --- a/config/hcl2shim/flatmap.go +++ b/config/hcl2shim/flatmap.go @@ -215,6 +215,12 @@ func hcl2ValueFromFlatmapObject(m map[string]string, prefix string, atys map[str func hcl2ValueFromFlatmapTuple(m map[string]string, prefix string, etys []cty.Type) (cty.Value, error) { var vals []cty.Value + // if the container is unknown, there is no count string + listName := strings.TrimRight(prefix, ".") + if m[listName] == UnknownVariableValue { + return cty.UnknownVal(cty.Tuple(etys)), nil + } + countStr, exists := m[prefix+"#"] if !exists { return cty.NullVal(cty.Tuple(etys)), nil @@ -247,6 +253,12 @@ func hcl2ValueFromFlatmapMap(m map[string]string, prefix string, ty cty.Type) (c vals := make(map[string]cty.Value) ety := ty.ElementType() + // if the container is unknown, there is no count string + listName := strings.TrimRight(prefix, ".") + if m[listName] == UnknownVariableValue { + return cty.UnknownVal(ty), nil + } + // We actually don't really care about the "count" of a map for our // purposes here, but we do need to check if it _exists_ in order to // recognize the difference between null (not set at all) and empty. @@ -288,6 +300,12 @@ func hcl2ValueFromFlatmapMap(m map[string]string, prefix string, ty cty.Type) (c func hcl2ValueFromFlatmapList(m map[string]string, prefix string, ty cty.Type) (cty.Value, error) { var vals []cty.Value + // if the container is unknown, there is no count string + listName := strings.TrimRight(prefix, ".") + if m[listName] == UnknownVariableValue { + return cty.UnknownVal(ty), nil + } + countStr, exists := m[prefix+"#"] if !exists { return cty.NullVal(ty), nil @@ -323,6 +341,12 @@ func hcl2ValueFromFlatmapSet(m map[string]string, prefix string, ty cty.Type) (c var vals []cty.Value ety := ty.ElementType() + // if the container is unknown, there is no count string + listName := strings.TrimRight(prefix, ".") + if m[listName] == UnknownVariableValue { + return cty.UnknownVal(ty), nil + } + // We actually don't really care about the "count" of a set for our // purposes here, but we do need to check if it _exists_ in order to // recognize the difference between null (not set at all) and empty.