-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssh public key forces replacement "azurerm_linux_virtual_machine" #9238
Comments
Hi, Regards |
Hi @DenWin , When I modify the .pub file to heredoc format, I lose the public key format. How can i change the format of the .pub file to heredoc format? Thank you very much for the answer. Regards |
do you need this file anywhere else? Also I'm not that familiar with that, but I'm rather sure that a public key is valid no matter how it is broken over into the next line, hence the here-doc version is as valid as the single line version. Even a completely odd broken here-doc version should still work - well not in Terraform where a character comparison takes place. |
Hi, @DenWin In multiline version, I tried with and without \r\n characters (included in the key as it displays in the terraform state file) but the error is still the same with heredoc syntax. But if I use \n or \r\n Terraform raises parsing error. Thanks in advance |
Hi @jorchis05 / @DenWin |
@jackofallops : I'm out here, just tried to give additional advice without knowledge about actual issue at hand. |
The keyPair, in my case, was created through the Portal (you can see "generated by azure" at the end of the key) along with the VM. |
Hi @jackofallops , to reproduce you can:
If you try to write the keys in different ways ("with \r\n, \r, on multiple line, changing the encoding and so on") you always fall inside one of the validation branch present in the function: if you format the string to pass the validation (single line), the difference is detected, due to the \r\n retrieved by the provider that are not recognized by the local tf code representation. If you reset the SSH key in the portal, the new key is appended to the existing one in the machine. |
Thanks @frontegi - I'll continue to look into this. |
Thanks @jackofallops for the effort in solving this issue. |
Thanks @jackofallops for the help! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
This issue was originally opened by @jorchis05 as hashicorp/terraform#26862. It was migrated here as a result of the provider split. The original body of the issue is below.
Good morning,
We have an infrastructure generated in Azure which we are terraforming with the Terraformer tool.
Once we have the infrastructure code we are having problems with the resource "azurerm_linux_virtual_machine" and with the admin_ssh_key "public_key".
Our virtual machine has a linked ssh key. Which we reference through a .pub file and with the following code:
admin_ssh_key {
username = "dam"
public_key = file("~/.ssh/public_key.pub")
}
After performing the command terraform plan we realize that it tries to replace the public_key because the information that Terraform collects from the public key is in heredoc format with carriage returns and our .pub file does not have them.
Attached is a screenshot of the terraform plan.
Could you help us with this case?
Versions:
Terraform v0.12.29
Provider azurerm: 2.20.0
Terraformer: v0.8.9
Thank you very much.
Regards.
The text was updated successfully, but these errors were encountered: