I am new at Terraform and would like some help. I have successfully created a VM and can manually SSH into it with no problem. The issue is I am working with a team on a project and they can't do any changes to the Tf files without making Terraform delete all the resources and recreating them. I think this is because they have a different SSH Key from mines.
admin_ssh_key {
username = "azureroot"
public_key = file("~/.ssh/id_rsa.pub")}
Because the contents of my ssh key is different from my teammates, it will destroy the VM and recreate it using the key from the person who did the terraform apply. Is there any way to get around this? This has caused many issues because we have had multiple vms destroyed because of the keys were different.
cloud-init
wherein you could add the user and keys but Azurewaagent
needs to be told and you may have problems while snapshotting the instance because of stale user data. I don't understand why both the teams are creating the same resource.. – harshavmbpublic_key - (Required) The Public Key which should be used for authentication, which needs to be at least 2048-bit and in ssh-rsa format. Changing this forces a new resource to be created.
Refer this:: terraform.io/docs/providers/azurerm/r/… – harshavmb