diff --git a/README.md b/README.md index 1085a142..48dff614 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/examples/default/README.md b/examples/default/README.md deleted file mode 100644 index 775d8fac..00000000 --- a/examples/default/README.md +++ /dev/null @@ -1,141 +0,0 @@ - -# Default example - -This deploys the module in its simplest form. - -```hcl -terraform { - required_version = ">= 1.3.0" - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = ">= 3.7.0, < 4.0.0" - } - random = { - source = "hashicorp/random" - version = ">= 3.5.0, < 4.0.0" - } - } -} - -provider "azurerm" { - features {} -} - - -## Section to provide a random Azure region for the resource group -# This allows us to randomize the region for the resource group. -module "regions" { - source = "Azure/regions/azurerm" - version = ">= 0.3.0" -} - -# This allows us to randomize the region for the resource group. -resource "random_integer" "region_index" { - max = length(module.regions.regions) - 1 - min = 0 -} -## End of section to provide a random Azure region for the resource group - -# This ensures we have unique CAF compliant names for our resources. -module "naming" { - source = "Azure/naming/azurerm" - version = ">= 0.3.0" -} - -# This is required for resource modules -resource "azurerm_resource_group" "this" { - location = module.regions.regions[random_integer.region_index.result].name - name = module.naming.resource_group.name_unique -} - -# 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 -# with a data source. -module "test" { - source = "../../" - # source = "Azure/avm--/azurerm" - # ... - enable_telemetry = var.enable_telemetry # see variables.tf - name = module.naming.kubernetes_cluster.name_unique - resource_group_name = azurerm_resource_group.this.name -} -``` - - -## Requirements - -The following requirements are needed by this module: - -- [terraform](#requirement\_terraform) (>= 1.3.0) - -- [azurerm](#requirement\_azurerm) (>= 3.7.0, < 4.0.0) - -- [random](#requirement\_random) (>= 3.5.0, < 4.0.0) - -## Providers - -The following providers are used by this module: - -- [azurerm](#provider\_azurerm) (>= 3.7.0, < 4.0.0) - -- [random](#provider\_random) (>= 3.5.0, < 4.0.0) - -## Resources - -The following resources are used by this module: - -- [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource) -- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource) - - -## Required Inputs - -No required inputs. - -## Optional Inputs - -The following input variables are optional (have default values): - -### [enable\_telemetry](#input\_enable\_telemetry) - -Description: This variable controls whether or not telemetry is enabled for the module. -For more information see . -If it is set to false, then no telemetry will be collected. - -Type: `bool` - -Default: `true` - -## Outputs - -No outputs. - -## Modules - -The following Modules are called: - -### [naming](#module\_naming) - -Source: Azure/naming/azurerm - -Version: >= 0.3.0 - -### [regions](#module\_regions) - -Source: Azure/regions/azurerm - -Version: >= 0.3.0 - -### [test](#module\_test) - -Source: ../../ - -Version: - - -## Data Collection - -The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at . You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. - \ No newline at end of file diff --git a/examples/default/main.tf b/examples/default/main.tf index d329cf07..95fb1fc9 100644 --- a/examples/default/main.tf +++ b/examples/default/main.tf @@ -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 diff --git a/main.tf b/main.tf index 34fff4e0..ba41f3fa 100644 --- a/main.tf +++ b/main.tf @@ -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) @@ -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 } } }