puppet_prefix: Generate YAML with yamlencode equivalent
Convert API response Hiera data to YAML using the same
ctyyaml.YAMLEncodeFunc encoder as Tofu uses internally to power the
yamlencode HCL function. Presenting the stored Hiera data in this way
avoids dirty diff problems which arise when YAML encoders with different
settings for string quoting and other structural YAML representations
are used.
A remaining dirty diff source is reading Hiera config stored in a text
file with different YAML encoding than YAMLEncodeFunc produces.
A workaround for this is round tripping the YAML data through the HCL
yamldecode and yamlencode functions:
hiera = yamlencode(
yamldecode(
file("${path.module}/prefix_hiera.yaml")
)
)