Skip to content

Create multiple role assignments #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion terraform/azure-devops/create-service-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,26 @@ module azure_access {
azurerm = azurerm.target
}
source = "./modules/azure-access"
create_role_assignment = !var.azdo_creates_identity
# create_role_assignment = !var.azdo_creates_identity
create_role_assignment = true
identity_object_id = local.principal_id
resource_id = local.azure_scope
role = var.azure_role
}

module azure_role_assignments {
providers = {
azurerm = azurerm.target
}
source = "./modules/azure-access"
create_role_assignment = !var.azdo_creates_identity
identity_object_id = local.principal_id
resource_id = each.value.scope
role = each.value.role

for_each = { for ra in var.azure_role_assignments : format("%s-%s", ra.scope, ra.role) => ra }
}

module service_connection {
source = "./modules/service-connection"
application_id = local.application_id
Expand Down
6 changes: 6 additions & 0 deletions terraform/azure-devops/create-service-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ variable azure_role {
nullable = false
}

variable azure_role_assignments {
default = []
nullable = true
type = set(object({scope=string, role=string}))
}

variable create_federation {
description = "Use workload identity federation instead of a App Registration secret"
default = true
Expand Down