Skip to content

Commit

Permalink
Set owner in service principal/app creation (ESC-1593) (#53)
Browse files Browse the repository at this point in the history
Set owner in service principal/app creation (ESC-1593) 

Co-authored-by: iru <[email protected]>
  • Loading branch information
Alex Qiu and iru authored Jan 11, 2022
1 parent 18d4928 commit 34c5d77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/infrastructure/enterprise_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions modules/infrastructure/enterprise_app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 34c5d77

Please sign in to comment.