From 99fa801597f74fcca13775260112f839ad7712cb Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Fri, 26 May 2023 16:21:01 -0700 Subject: [PATCH] Moved code into sp.tf to make it more self-contained --- quickstart/201-k8s-cluster-with-tf-and-aks/main.tf | 6 ------ quickstart/201-k8s-cluster-with-tf-and-aks/sp.tf | 14 ++++++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/quickstart/201-k8s-cluster-with-tf-and-aks/main.tf b/quickstart/201-k8s-cluster-with-tf-and-aks/main.tf index ee4cf410..66f9facd 100644 --- a/quickstart/201-k8s-cluster-with-tf-and-aks/main.tf +++ b/quickstart/201-k8s-cluster-with-tf-and-aks/main.tf @@ -8,12 +8,6 @@ resource "azurerm_resource_group" "rg" { name = random_pet.rg_name.id } -data "azurerm_client_config" "current" {} - -locals { - current_user_id = coalesce(var.msi_id, data.azurerm_client_config.current.object_id) -} - resource "random_pet" "azurerm_kubernetes_cluster_name" { prefix = "cluster" } diff --git a/quickstart/201-k8s-cluster-with-tf-and-aks/sp.tf b/quickstart/201-k8s-cluster-with-tf-and-aks/sp.tf index adde9182..8fdba63e 100644 --- a/quickstart/201-k8s-cluster-with-tf-and-aks/sp.tf +++ b/quickstart/201-k8s-cluster-with-tf-and-aks/sp.tf @@ -1,17 +1,23 @@ -# Create Azure AD App Registration +data "azurerm_client_config" "current" {} + +locals { + current_user_id = coalesce(var.msi_id, data.azurerm_client_config.current.object_id) +} + +# Create Azure AD app registration. resource "azuread_application" "app" { display_name = "my-app" owners = [local.current_user_id] } -# Create Service Principal +# Create service principal. resource "azuread_service_principal" "app" { application_id = azuread_application.app.application_id app_role_assignment_required = true owners = [local.current_user_id] } -# Create Service Principal password +# Create service principal password. resource "azuread_service_principal_password" "app" { service_principal_id = azuread_service_principal.app.id } @@ -25,7 +31,7 @@ resource "time_sleep" "wait_30_seconds" { depends_on = [azuread_service_principal_password.app] } -# Output the Service Principal and password +# Output the service principal and password. output "sp" { value = azuread_service_principal.app.id sensitive = true