imported SSH keys contain newlines "\r\n"
Problem:
terraform plan Error: parsing "admin_ssh_key.0.public_key" as a public key object or Error: decoding "public_key" for public key data
main.aztfexport.tf contains \r\n multiple times inside public key
resource "azurerm_ssh_public_key" "res-4" {
location = "eastus"
name = "vm_key"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDg6i01BFp7R6i1xImXnOsR3OzT\r\nfBsk.....ZV\r\nSO.....5oLpk= generated-by-azure\r\n
Workaround:
sed -i 's|\\r\\n||g' main.aztfexport.tf
Info:
- Windows, Bash
- aztfexport version v0.18.0(c787766)
After fix, terraform plan shows newline-ed SSH key block, that it will replace with a singleline string.
So this may very well be the way Azure saved key itself - the edge case.
@needleshaped Thanks for reaching out! I've tested with both letting Azure creating a key and I upload my own key, both keys have no new line in its original form, as well as the exported TF config.
For your case, I suspect it's due to the original key contains those new lines, which was then uploaded and saved in Azure as such.