diff --git a/.github/settings.json b/.github/settings.json index bb9877c..fcabfbe 100644 --- a/.github/settings.json +++ b/.github/settings.json @@ -1,11 +1,12 @@ { "repos": { - "description": "A Terraform module that manages the tpl_resources resources from the azurerm provider.", + "description": "A Terraform module that manages the authorization resources from the azurerm provider.", "visibility": "public", "default_branch": "main", "topics": [ "terraform", - "azure" + "azure", + "role-assignment" ] } } diff --git a/examples/apply_main.tf b/examples/apply_main.tf index 5b014c4..e69de29 100644 --- a/examples/apply_main.tf +++ b/examples/apply_main.tf @@ -1,9 +0,0 @@ -module "tpl_module" { - source = "tpl_source" - tpl_local_name = { - tpl_name = { - location = "westeurope" - resource_group_name = "rg-mms-github" - } - } -} diff --git a/examples/full_main.tf b/examples/full_main.tf index 23f22b7..e69de29 100644 --- a/examples/full_main.tf +++ b/examples/full_main.tf @@ -1,14 +0,0 @@ -module "tpl_module" { - source = "tpl_source" - tpl_local_name = { - tpl_name = { - location = "westeurope" - resource_group_name = "rg-mms-github" - tags = { - project = "mms-github" - environment = terraform.workspace - managed-by = "terraform" - } - } - } -} diff --git a/examples/min_main.tf b/examples/min_main.tf index 5b014c4..e69de29 100644 --- a/examples/min_main.tf +++ b/examples/min_main.tf @@ -1,9 +0,0 @@ -module "tpl_module" { - source = "tpl_source" - tpl_local_name = { - tpl_name = { - location = "westeurope" - resource_group_name = "rg-mms-github" - } - } -} diff --git a/main.tf b/main.tf index d75abd8..0795f3f 100644 --- a/main.tf +++ b/main.tf @@ -1,15 +1,22 @@ /** -* # tpl_module +* # authorization * -* This module manages the tpl_provider tpl_module resources. -* For more information see https://registry.terraform.io/providers/tpl_provider/latest/docs > tpl_module +* This module manages the azurerm authorization resources. +* For more information see https://registry.terraform.io/providers/azurerm/latest/docs > authorization * */ -resource "tpl_resource_type" "tpl_local_name" { - for_each = var.tpl_local_name +resource "azurerm_role_assignment" "role_assignment" { + for_each = var.role_assignment - name = local.tpl_local_name[each.key].name == "" ? each.key : local.tpl_local_name[each.key].name - - tags = local.tpl_local_name[each.key].tags + name = local.role_assignment[each.key].name + scope = local.role_assignment[each.key].scope + role_definition_id = local.role_assignment[each.key].role_definition_id + role_definition_name = local.role_assignment[each.key].role_definition_name + principal_id = local.role_assignment[each.key].principal_id + condition = local.role_assignment[each.key].condition + condition_version = local.role_assignment[each.key].condition_version + delegated_managed_identity_resource_id = local.role_assignment[each.key].delegated_managed_identity_resource_id + description = local.role_assignment[each.key].description + skip_service_principal_aad_check = local.role_assignment[each.key].skip_service_principal_aad_check } diff --git a/outputs.tf b/outputs.tf index 88502f7..e84069c 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,9 +1,9 @@ -output "tpl_local_name" { +output "role_assignments" { description = "Outputs all attributes of resource_type." value = { - for tpl_local_name in keys(tpl_resource_type.tpl_local_name) : - tpl_local_name => { - for key, value in tpl_resource_type.tpl_local_name[tpl_local_name] : + for role_assignment in keys(azurerm_role_assignment.role_assignment) : + role_assignment => { + for key, value in azurerm_role_assignment.role_assignment[role_assignment] : key => value } } @@ -17,9 +17,9 @@ output "variables" { variable => local.default[variable] } merged = { - tpl_local_name = { - for key in keys(var.tpl_local_name) : - key => local.tpl_local_name[key] + role_assignment = { + for key in keys(var.role_assignment) : + key => local.role_assignment[key] } } } diff --git a/providers.tf b/providers.tf index e69de29..ab91b24 100644 --- a/providers.tf +++ b/providers.tf @@ -0,0 +1,3 @@ +provider "azurerm" { + features {} +} diff --git a/tests/terratest.yaml b/tests/terratest.yaml index a36c138..6123e50 100644 --- a/tests/terratest.yaml +++ b/tests/terratest.yaml @@ -1,3 +1,2 @@ -# see https://pkg.go.dev/github.com/gruntwork-io/terratest/modules/[package] functions: [] options: {} diff --git a/variables.tf b/variables.tf index 83a51c1..2539e4f 100644 --- a/variables.tf +++ b/variables.tf @@ -1,4 +1,4 @@ -variable "tpl_local_name" { +variable "role_assignment" { type = any default = {} description = "Resource definition, default settings are defined within locals and merged with var settings. For more information look at [Outputs](#Outputs)." @@ -6,27 +6,30 @@ variable "tpl_local_name" { locals { default = { - tpl_local_name = { - name = "" - tags = {} + // resource definition + role_assignment = { + name = null + role_definition_id = null + role_definition_name = null + condition = null + condition_version = null + delegated_managed_identity_resource_id = null + description = null + skip_service_principal_aad_check = null } } - /** - compare and merge custom and default values - */ - tpl_local_name_values = { - for tpl_local_name in keys(var.tpl_local_name) : - tpl_local_name => merge(local.default.tpl_local_name, var.tpl_local_name[tpl_local_name]) + // compare and merge custom and default values + role_assignment_values = { + for role_assignment in keys(var.role_assignment) : + role_assignment => merge(local.default.role_assignment, var.role_assignment[role_assignment]) } - /** - deep merge of all custom and default values - */ - tpl_local_name = { - for tpl_local_name in keys(var.tpl_local_name) : - tpl_local_name => merge( - local.tpl_local_name_values[tpl_local_name], + // deep merge of all custom and default values + role_assignment = { + for role_assignment in keys(var.role_assignment) : + role_assignment => merge( + local.role_assignment_values[role_assignment], {} ) } diff --git a/versions.tf b/versions.tf index 57e25f3..54d2ced 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,9 @@ terraform { required_providers { + azurerm = { + source = "registry.terraform.io/hashicorp/azurerm" + version = ">=3.59.0" + } } - required_version = ">=1.3" + required_version = ">=1.4" }