From 34c5d772e11779dda4bc146e3dcf593525b7e365 Mon Sep 17 00:00:00 2001 From: Alex Qiu Date: Tue, 11 Jan 2022 11:39:44 -0800 Subject: [PATCH] Set owner in service principal/app creation (ESC-1593) (#53) Set owner in service principal/app creation (ESC-1593) Co-authored-by: iru --- .pre-commit-config.yaml | 4 ++-- modules/infrastructure/enterprise_app/README.md | 1 + modules/infrastructure/enterprise_app/main.tf | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53421cc..50a3adf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: - - repo: git://github.com/antonbabenko/pre-commit-terraform + - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.50.0 hooks: - id: terraform_fmt @@ -23,7 +23,7 @@ repos: - '--args=--only=terraform_required_providers' - '--args=--only=terraform_standard_module_structure' - '--args=--only=terraform_workspace_remote' - - repo: git://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 hooks: - id: check-merge-conflict diff --git a/modules/infrastructure/enterprise_app/README.md b/modules/infrastructure/enterprise_app/README.md index fce0fd0..883f575 100644 --- a/modules/infrastructure/enterprise_app/README.md +++ b/modules/infrastructure/enterprise_app/README.md @@ -34,6 +34,7 @@ No modules. | [azuread_service_principal_password.aspp](https://registry.terraform.io/providers/hashicorp/azuread/2.7.0/docs/resources/service_principal_password) | resource | | [azurerm_role_assignment.main](https://registry.terraform.io/providers/hashicorp/azurerm/2.85.0/docs/resources/role_assignment) | resource | | [azurerm_role_definition.ard](https://registry.terraform.io/providers/hashicorp/azurerm/2.85.0/docs/resources/role_definition) | resource | +| [azuread_client_config.current](https://registry.terraform.io/providers/hashicorp/azuread/2.7.0/docs/data-sources/client_config) | data source | ## Inputs diff --git a/modules/infrastructure/enterprise_app/main.tf b/modules/infrastructure/enterprise_app/main.tf index fa8df42..e7cc82e 100644 --- a/modules/infrastructure/enterprise_app/main.tf +++ b/modules/infrastructure/enterprise_app/main.tf @@ -2,12 +2,20 @@ locals { scopes = toset([for s in var.subscription_ids : "/subscriptions/${s}"]) } +data "azuread_client_config" "current" {} + resource "azuread_application" "aa" { display_name = "${var.name}-sd-app" + owners = [ + data.azuread_client_config.current.object_id + ] } resource "azuread_service_principal" "asp" { application_id = azuread_application.aa.application_id + owners = [ + data.azuread_client_config.current.object_id + ] } resource "azuread_service_principal_password" "aspp" {