diff --git a/map.go b/map.go index f442fd9..5454ecb 100644 --- a/map.go +++ b/map.go @@ -185,7 +185,12 @@ func (r *rover) GenerateModuleMap(parent *Resource, parentModule string) { tcr := &Resource{ Type: rs.Type, - Name: strings.TrimPrefix(crName, fmt.Sprintf("%s%s.", prefix, re.ResourceType)), + } + + if rs.Type == ResourceTypeData { + tcr.Name = strings.TrimPrefix(crName, fmt.Sprintf("%sdata.%s.", prefix, re.ResourceType)) + } else { + tcr.Name = strings.TrimPrefix(crName, fmt.Sprintf("%s%s.", prefix, re.ResourceType)) } if cr.Change.Actions != nil { @@ -206,16 +211,32 @@ func (r *rover) GenerateModuleMap(parent *Resource, parentModule string) { if rs.Type == ResourceTypeData { ind = fmt.Sprintf("data.%s", ind) + } + + if rs.Type == ResourceTypeData && configs[parentConfig].Module.DataResources[ind] != nil { + fname = filepath.Base(configs[parentConfig].Module.DataResources[ind].Pos.Filename) re.Line = &configs[parentConfig].Module.DataResources[ind].Pos.Line - } else if rs.Type == ResourceTypeResource { + + r.AddFileIfNotExists(parent, parentModule, fname) + + parent.Children[fname].Children[id] = re + + } else if rs.Type == ResourceTypeResource && configs[parentConfig].Module.ManagedResources[ind] != nil { + fname = filepath.Base(configs[parentConfig].Module.ManagedResources[ind].Pos.Filename) re.Line = &configs[parentConfig].Module.ManagedResources[ind].Pos.Line - } - r.AddFileIfNotExists(parent, parentModule, fname) + r.AddFileIfNotExists(parent, parentModule, fname) - parent.Children[fname].Children[id] = re + parent.Children[fname].Children[id] = re + + } else { + + r.AddFileIfNotExists(parent, parentModule, DefaultFileName) + + parent.Children[DefaultFileName].Children[id] = re + } } else { diff --git a/rso.go b/rso.go index 8ebc132..be9deae 100644 --- a/rso.go +++ b/rso.go @@ -211,16 +211,7 @@ func (r *rover) PopulateModuleState(rso *ResourcesOverview, module *tfjson.State } else { rs[id].Change.After = rst.AttributeValues } - - } else { - if prior { - rs[id].Change.Before = rst.AttributeValues - } else { - rs[id].Change.After = rst.AttributeValues - - } } - } for _, childModule := range module.ChildModules {