-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Api management support multiple roles validation AB#22184 (#440)
* Api management support multiple roles validation * fix fmt * adding service principal role assignments * resolving PR comments * fix formating
- Loading branch information
1 parent
632020e
commit c99e758
Showing
5 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
modules/azure/application_service_principal_role_assignment/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
terraform { | ||
required_version = "~> 1.3" | ||
|
||
required_providers { | ||
azuread = { | ||
source = "hashicorp/azuread" | ||
version = "~> 2.36" | ||
} | ||
} | ||
|
||
backend "azurerm" {} | ||
} | ||
|
||
provider "azuread" {} | ||
|
||
resource "azuread_service_principal" "internal" { | ||
for_each = toset([for assignment in var.assignments : assignment.client_id]) | ||
client_id = each.key | ||
use_existing = var.use_existing_service_principal | ||
} | ||
|
||
resource "azuread_app_role_assignment" "role_assignment" { | ||
for_each = { | ||
for assignment in var.assignments : | ||
"${assignment.role_id}_${assignment.object_id}_${assignment.client_id}" => assignment | ||
} | ||
app_role_id = each.value.role_id | ||
principal_object_id = each.value.object_id | ||
resource_object_id = azuread_service_principal.internal[each.value.client_id].object_id | ||
} |
Empty file.
13 changes: 13 additions & 0 deletions
13
modules/azure/application_service_principal_role_assignment/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
variable "assignments" { | ||
type = list(object({ | ||
object_id = string, | ||
role_id = string, | ||
client_id = string | ||
})) | ||
description = "The assignments you want to add to an application." | ||
} | ||
variable "use_existing_service_principal" { | ||
type = bool | ||
default = false | ||
description = "When true, any existing service principal linked to the same application will be automatically imported. When false, an import error will be raised for any pre-existing service principal." | ||
} |