From d576aedff157622146f8870f0eda9360c1984a8d Mon Sep 17 00:00:00 2001 From: "Phillip T. George" Date: Sun, 24 Nov 2019 10:57:20 -0600 Subject: [PATCH] Fix #130 - Google was bot working due to lack of recursion on attributes parsing --- parser.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/parser.go b/parser.go index 8d05d88..0cfbf36 100644 --- a/parser.go +++ b/parser.go @@ -1,5 +1,6 @@ package main + import ( "encoding/json" "fmt" @@ -289,6 +290,11 @@ func encodeTerraform0Dot12ValuesAsAttributes(rawValues *map[string]interface{}) for kk, vv := range v { if str, typeOk := vv.(string); typeOk { ret[k+"."+strconv.Itoa(kk)] = str + } else if mi, typeOk := vv.(map[string]interface{}); typeOk { + attribs := encodeTerraform0Dot12ValuesAsAttributes(&mi) + for k3, v3 := range attribs { + ret[k+"."+strconv.Itoa(kk)+"."+k3] = v3 + } } else { ret[k+"."+strconv.Itoa(kk)] = "" } @@ -312,7 +318,6 @@ func (s *stateTerraform0dot12) resources() []*Resource { if !typeOk { continue } - if strings.HasPrefix(rs.Address, "data.") { // This does not represent a host (e.g. AWS AMI) continue @@ -326,7 +331,6 @@ func (s *stateTerraform0dot12) resources() []*Resource { if rs.Index != nil { resourceKeyName += "." + strconv.Itoa(*rs.Index) } - // Terraform stores resources in a name->map map, but we need the name to // decide which groups to include the resource in. So wrap it in a higher- // level object with both properties.