User Story 125263 (#238)
* Updated to use AzApi to obtain SSH (instead of tls)
This commit is contained in:
@ -101,7 +101,7 @@ resource "azurerm_linux_virtual_machine" "test" {
|
||||
}
|
||||
|
||||
admin_ssh_key {
|
||||
username = coalesce(var.username, "azureuser")
|
||||
username = var.username
|
||||
public_key = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ resource "azurerm_linux_virtual_machine" "test" {
|
||||
}
|
||||
|
||||
computer_name = "hostname"
|
||||
admin_username = coalesce(var.username, "azureuser")
|
||||
admin_username = var.username
|
||||
}
|
||||
|
||||
resource "azurerm_managed_disk" "test" {
|
||||
|
@ -3,23 +3,22 @@ resource "random_pet" "ssh_key_name" {
|
||||
separator = ""
|
||||
}
|
||||
|
||||
resource "azapi_resource" "ssh_public_key" {
|
||||
type = "Microsoft.Compute/sshPublicKeys@2022-11-01"
|
||||
name = random_pet.ssh_key_name.id
|
||||
location = "westus3"
|
||||
parent_id = azurerm_resource_group.rg.id
|
||||
}
|
||||
|
||||
resource "azapi_resource_action" "ssh_public_key_gen" {
|
||||
type = "Microsoft.Compute/sshPublicKeys@2022-11-01"
|
||||
resource_id = azapi_resource.ssh_public_key.id
|
||||
action = "generateKeyPair"
|
||||
method = "POST"
|
||||
|
||||
response_export_values = ["publicKey"]
|
||||
response_export_values = ["publicKey", "privateKey"]
|
||||
}
|
||||
|
||||
resource "azapi_resource" "ssh_public_key" {
|
||||
type = "Microsoft.Compute/sshPublicKeys@2022-11-01"
|
||||
name = random_pet.ssh_key_name.id
|
||||
location = azurerm_resource_group.rg.location
|
||||
parent_id = azurerm_resource_group.rg.id
|
||||
}
|
||||
|
||||
output "key_data" {
|
||||
value = azapi_resource.ssh_public_key.body
|
||||
sensitive = true
|
||||
value = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey
|
||||
}
|
Reference in New Issue
Block a user