User Story 125263 (#238)

* Updated to use AzApi to obtain SSH (instead of tls)
This commit is contained in:
Tom Archer
2023-07-23 18:01:38 -07:00
committed by GitHub
parent b405c2cce8
commit 58245fa62c
12 changed files with 70 additions and 45 deletions

View File

@ -32,7 +32,7 @@ resource "azurerm_kubernetes_cluster" "k8s" {
node_count = var.node_count
}
linux_profile {
admin_username = "ubuntu"
admin_username = var.username
ssh_key {
key_data = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey

View File

@ -22,6 +22,7 @@ This template provisions an [AKS / Azure Kubernetes service (also known as a Man
| `resource_group_location` | Location of the resource group. | eastus |
| `node_count` | Initial number of nodes which should exist in this Node Pool. Value must be between 1 and 1000. | 3 |
| `msi_id` | The Managed Service Identity ID. Set this value if you're running this example using Managed Identity as the authentication method. | null |
| `username` | The username for the new cluster. | azureadmin |
## Example

View File

@ -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
}

View File

@ -20,4 +20,10 @@ variable "msi_id" {
type = string
description = "The Managed Service Identity ID. Set this value if you're running this example using Managed Identity as the authentication method."
default = null
}
variable "username" {
type = string
description = "The admin username for the new cluster."
default = "azureadmin"
}