Returns a JSON output in format 'map[string]=string' where the key is set to the id and the value is set to the name or selected attribute value of the resource
Returns a non-zero error code if the resource_type is not found which will be picked up by Terraform to error out, but a missing attribute will get a null value
# # Terraform state outputs control chars, remove them so grep will work - hard to remove all escape sequences and slow
# # we need literal escapes here
# # shellcheck disable=SC1117
# terraform state show "$resource_type.$resource" |
# sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" |
# # nested attributes, eg. branches have greater depth - this code is brittle but Terraform doesn't support -json for terraform state show unfortunately