Skip to content

Commit

Permalink
Support duplicate Role Definition deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Rowlandson committed Oct 5, 2020
1 parent 3186eb3 commit b4c7ce2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
3 changes: 0 additions & 3 deletions data.subscription.tf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
],
"role_assignments": [],
"role_definitions": [
"ES Network Subnet Contributor"
"ES-Network-Subnet-Contributor"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "Microsoft.Authorization/roleDefinitions",
"apiVersion": "2018-01-01-preview",
"properties": {
"roleName": "ES Network Subnet Contributor",
"roleName": "ES-Network-Subnet-Contributor",
"description": "Enterprise-scale custom Role Definition. Grants full access to manage Virtual Network subnets, but no other network resources.",
"type": "customRole",
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ locals {
locals {
builtin_role_definitions_map_from_json = try(length(local.builtin_role_definitions_dataset_from_json) > 0, false) ? {
for key, value in local.builtin_role_definitions_dataset_from_json :
value.name => value.properties
uuidv5(value.name, local.scope_id) => value.properties
if value.type == local.resource_types.role_definition
} : null
builtin_role_definitions_map_from_yaml = try(length(local.builtin_role_definitions_dataset_from_yaml) > 0, false) ? {
for key, value in local.builtin_role_definitions_dataset_from_yaml :
value.name => value.properties
uuidv5(value.name, local.scope_id) => value.properties
if value.type == local.resource_types.role_definition
} : null
custom_role_definitions_map_from_json = try(length(local.custom_role_definitions_dataset_from_json) > 0, false) ? {
for key, value in local.custom_role_definitions_dataset_from_json :
value.name => value.properties
uuidv5(value.name, local.scope_id) => value.properties
if value.type == local.resource_types.role_definition
} : null
custom_role_definitions_map_from_yaml = try(length(local.custom_role_definitions_dataset_from_yaml) > 0, false) ? {
for key, value in local.custom_role_definitions_dataset_from_yaml :
value.name => value.properties
uuidv5(value.name, local.scope_id) => value.properties
if value.type == local.resource_types.role_definition
} : null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ locals {
policy_definition = "${local.scope_id}/providers/Microsoft.Authorization/policyDefinitions/"
policy_set_definition = "${local.scope_id}/providers/Microsoft.Authorization/policySetDefinitions/"
role_assignment = "${local.scope_id}/providers/Microsoft.Authorization/roleAssignments/"
role_definition = "${local.scope_id}/providers/Microsoft.Authorization/roleDefinitions/"
role_definition = "/providers/Microsoft.Authorization/roleDefinitions/"
}
}
2 changes: 1 addition & 1 deletion resources.role_definitions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resource "azurerm_role_definition" "enterprise_scale" {
role_definition_id = basename(each.key)

# Mandatory resource attributes
name = each.value.template.roleName
name = "[${upper(local.es_root_id)}] ${each.value.template.roleName}"
scope = each.value.scope_id

permissions {
Expand Down

0 comments on commit b4c7ce2

Please sign in to comment.