User Story 90135

This commit is contained in:
Tom Archer
2023-05-12 08:52:11 -07:00
parent 3110ce9954
commit b4d429be35
8 changed files with 133 additions and 71 deletions

View File

@ -8,15 +8,19 @@ resource "azurerm_resource_group" "rg" {
name = random_pet.rg_name.id
}
resource "random_id" "log_analytics_workspace_name_suffix" {
byte_length = 8
data "azurerm_client_config" "current" {}
locals {
current_user_id = coalesce(var.msi_id, data.azurerm_client_config.current.object_id)
}
resource "random_pet" "azurerm_log_analytics_workspace_name" {
prefix = "ws"
}
resource "azurerm_log_analytics_workspace" "test" {
location = var.log_analytics_workspace_location
# The WorkSpace name has to be unique across the whole of azure;
# not just the current subscription/tenant.
name = "${var.log_analytics_workspace_name}-${random_id.log_analytics_workspace_name_suffix.dec}"
location = var.log_analytics_workspace_location
name = random_pet.azurerm_log_analytics_workspace_name.id
resource_group_name = azurerm_resource_group.rg.name
sku = var.log_analytics_workspace_sku
}
@ -34,25 +38,30 @@ resource "azurerm_log_analytics_solution" "test" {
}
}
resource "random_pet" "azurerm_kubernetes_cluster_name" {
prefix = "cluster"
}
resource "random_pet" "azurerm_kubernetes_cluster_dns_prefix" {
prefix = "dns"
}
resource "azurerm_kubernetes_cluster" "k8s" {
location = azurerm_resource_group.rg.location
name = var.cluster_name
name = random_pet.azurerm_kubernetes_cluster_name.id
resource_group_name = azurerm_resource_group.rg.name
dns_prefix = var.dns_prefix
tags = {
Environment = "Development"
}
dns_prefix = random_pet.azurerm_kubernetes_cluster_dns_prefix.id
default_node_pool {
name = "agentpool"
vm_size = "Standard_D2_v2"
node_count = var.agent_count
node_count = var.node_count
}
linux_profile {
admin_username = "ubuntu"
ssh_key {
key_data = file(var.ssh_public_key)
key_data = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey
}
}
network_profile {
@ -60,7 +69,7 @@ resource "azurerm_kubernetes_cluster" "k8s" {
load_balancer_sku = "standard"
}
service_principal {
client_id = var.aks_service_principal_app_id
client_secret = var.aks_service_principal_client_secret
client_id = azuread_service_principal.app.application_id
client_secret = azuread_service_principal_password.app.value
}
}
}