in pkg/terraform/root_block.go [140:158]
func NewBlock(m *Module, rb *hclsyntax.Block, wb *hclwrite.Block) *RootBlock {
b := &RootBlock{
Type: rb.Type,
Labels: rb.Labels,
Address: strings.Join(append([]string{rb.Type}, rb.Labels...), "."),
Block: rb,
WriteBlock: wb,
module: m,
}
if countAttr, ok := rb.Body.Attributes["count"]; ok {
b.Count = NewAttribute("count", countAttr, wb.Body().GetAttribute("count"))
}
if forEachAttr, ok := rb.Body.Attributes["for_each"]; ok {
b.ForEach = NewAttribute("for_each", forEachAttr, wb.Body().GetAttribute("for_each"))
}
b.Attributes = attributes(rb.Body, wb.Body())
b.NestedBlocks = nestedBlocks(rb.Body, wb.Body())
return b
}