I am converting my working build.tf script into several json equivalents resource.tf.json, data.tf.json, variable.tf.json, output.tf.json, terraform.tf.json, and provider.tf.json - so, one .tf.json file for each block type. I’m down to my LAST error which has thus far proved insurmountable. In my build.tf file the data block syntax that works is …
data “tls_public_key” “public_key” {
private_key_pem = file("${path.root}/keys/ssh_key.pem")
}
The equivalent data.tf.json syntax that does not work is …
{
“data”: {
“tls_public_key”: {
“public_key”: {
“private_key_pem”: “file(’${path.root}/keys/ssh_key.pem’)”
}
}
}
With the .tf.json files initialised, terraform plan and also terraform apply throw the same response … Error: failed to decode PEM block containing private key of type “unknown”.
If I initialise the build.tf file then plan and apply work without error.
Thanks in anticipation of any assistance. Stuart