in types/hcl.go [18:39]
func GetResourceBlock(workingDirectory, targetAddress string) (*hclwrite.Block, error) {
for _, file := range helper.ListHclFiles(workingDirectory) {
// #nosec G304
src, err := os.ReadFile(filepath.Join(workingDirectory, file.Name()))
if err != nil {
return nil, err
}
f, diag := hclwrite.ParseConfig(src, file.Name(), hcl.InitialPos)
if f == nil || diag != nil && diag.HasErrors() || f.Body() == nil {
continue
}
for _, block := range f.Body().Blocks() {
if block != nil && block.Type() == "resource" {
address := strings.Join(block.Labels(), ".")
if targetAddress == address {
return block, nil
}
}
}
}
return nil, nil
}