Skip to content

Commit

Permalink
update user assigned module to take in user params
Browse files Browse the repository at this point in the history
  • Loading branch information
nellyk committed Feb 2, 2024
1 parent 72eecd6 commit 6bad117
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 150 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ The following resources are used by this module:
- [azurerm_private_endpoint_application_security_group_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint_application_security_group_association) (resource)
- [azurerm_resource_group_template_deployment.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group_template_deployment) (resource)
- [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [azurerm_user_assigned_identity.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) (resource)
- [random_id.telem](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) (resource)
- [azurerm_resource_group.parent](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source)

Expand Down
141 changes: 0 additions & 141 deletions examples/default/README.md

This file was deleted.

6 changes: 6 additions & 0 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ resource "azurerm_resource_group" "this" {
name = module.naming.resource_group.name_unique
}

resource "azurerm_user_assigned_identity" "main" {
location = azurerm_resource_group.rg.location
name = "uami-${module.naming.kubernetes_cluster.name}"
resource_group_name = azurerm_resource_group.rg.name
}

# This is the module call
# Do not specify location here due to the randomization above.
# Leaving location as `null` will cause the module to use the resource group location
Expand Down
10 changes: 2 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ data "azurerm_resource_group" "parent" {
name = var.resource_group_name
}

resource "azurerm_user_assigned_identity" "this" {
location = coalesce(var.location, local.resource_group_location)
name = "${var.name}-identity"
resource_group_name = var.resource_group_name
}

resource "azurerm_kubernetes_cluster" "this" {
location = coalesce(var.location, local.resource_group_location)
Expand Down Expand Up @@ -43,11 +38,10 @@ resource "azurerm_kubernetes_cluster" "this" {
tags = merge(var.tags, var.agents_tags)
}
dynamic "identity" {
for_each = var.client_id == "" || var.client_secret == "" ? ["identity"] : []

for_each = var.identity_ids != null ? [var.identity_ids] : []
content {
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.this.id]
identity_ids = var.identity_ids
}
}
}
Expand Down

0 comments on commit 6bad117

Please sign in to comment.