-
Notifications
You must be signed in to change notification settings - Fork 0
docs(azure-mi): update docs and added examples #901
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| formatter: "markdown" # this is required | ||
|
|
||
| version: "" | ||
|
|
||
| header-from: docs/header.md | ||
| footer-from: docs/footer.md | ||
|
|
||
| recursive: | ||
| enabled: false | ||
| path: modules | ||
| include-main: true | ||
|
|
||
| sections: | ||
| hide: [] | ||
| show: [] | ||
|
|
||
| content: "" | ||
|
|
||
| output: | ||
| file: "README.md" | ||
| mode: inject | ||
| template: |- | ||
| <!-- BEGIN_TF_DOCS --> | ||
| {{ .Content }} | ||
| <!-- END_TF_DOCS --> | ||
|
|
||
| output-values: | ||
| enabled: false | ||
| from: "" | ||
|
|
||
| sort: | ||
| enabled: true | ||
| by: name | ||
|
|
||
| settings: | ||
| anchor: true | ||
| color: true | ||
| default: true | ||
| description: false | ||
| escape: true | ||
| hide-empty: false | ||
| html: true | ||
| indent: 2 | ||
| lockfile: true | ||
| read-comments: true | ||
| required: true | ||
| sensitive: true | ||
| type: true |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,44 +1,27 @@ | ||||||
| ## Requirements | ||||||
|
|
||||||
| | Name | Version | | ||||||
| |------|---------| | ||||||
| | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.7.5 | | ||||||
|
|
||||||
| ## Providers | ||||||
|
|
||||||
| | Name | Version | | ||||||
| |------|---------| | ||||||
| | <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | = 4.16.0 | | ||||||
| <!-- BEGIN_TF_DOCS --> | ||||||
| # Azure Managed Identity Terraform Module | ||||||
|
|
||||||
| ## Resources | ||||||
| ## Overview | ||||||
|
|
||||||
| | Name | Type | | ||||||
| |------|------| | ||||||
| | [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group.html) | data resource (only when `tags from resource group` is enabled) | | ||||||
| | [azurerm_user_assigned_identity](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | source | | ||||||
| | [azurerm_role_assignment](https://registry.terraform.io/providers/hashicorp/azurerm/2.62.1/docs/resources/role_assignment) | source | | ||||||
| | [azurerm_federated_identity_credential](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | source (only when `federated_credentials` is not empty) | | ||||||
|
|
||||||
| ## Inputs | ||||||
| This Terraform module allows you to create and manage a User Assigned Managed Identity in Azure, with support for: | ||||||
| - Custom RBAC role assignments. | ||||||
| - Federated credentials for GitHub, Kubernetes, or other issuers. | ||||||
| - Tag inheritance from the resource group. | ||||||
| - Flexible audience configuration for federated credentials. | ||||||
|
|
||||||
| | Name | Description | Type | Default | Required | | ||||||
| |------|-------------|------|---------|:--------:| | ||||||
| | name | The name of the Managed Identity | `string` | n/a | yes | | ||||||
| | resource_group | The name of the resource group in which to create the Managed Identity | `string` | n/a | yes | | ||||||
| | location | The location in which to create the Managed Identity | `string` | n/a | yes | | ||||||
| | tags | A mapping of tags to assign to the resource | `map(string)` | n/a | no | | ||||||
| | tags_from_rg | If true, the tags from the resource group will be inherited exclusively | `bool` | `false` | no | | ||||||
| | rbac | A list of role-based access control (RBAC) policies to apply to the Managed Identity | <pre>list(object({<br> name: string (required)<br> scope: string (required)<br> roles: list(string) (required)<br>}))</pre> | n/a | yes | | ||||||
| | federated_credentials | A list of federated credentials to assign to the Managed Identity, posible types are:<br><br>**kubernetes**: `issuer`, `namespace` and `service_account_name`<br>- `issuer`: The cluster issuer<br>- `namespace`: The namespace of the service account<br>- `service_account_name`: The name of the service account<br><br>**github**: `issuer`, `organization`, `repository` and `entity`<br>- `issuer`: The github issuer<br>- `organization`: The github organization<br>- `repository`: The github repository<br>- `entity`: The github entity \|Optional value, if not provided, the entity will be the repository. For other scenarios, the entity should be provided:<br> - environment: `environment:foo_enviroment`<br> - tags: `ref:refs/tags/foo_tag`<br> - branch: `ref:refs/heads/foo_branch`<br> - commit: `ref:refs/commits/foo_commit`<br><br>**other**: `issuer` and `subject`<br>- `issuer`: The issuer<br>- `subject`: The subject | <pre>list(object({<br> name: string (required)<br> type: string (required) - **kubernetes** \|\| **github** \|\| **other**<br> issuer: string (required only when type is **kubernetes** or **other**, when type is **github** is optional because the default is `https://token.actions.githubusercontent.com`)<br> namespace: string (required only when the type is **kubernetes**)<br> service_account_name: string (required only when the type is **kubernetes**)<br> organization: string (required only when the type is **github**)<br> repository: string (required only when the type is **github**)<br> entity: string (required only when the type is **github** and the entity is not the repository)<br> subject: string (required only when the type is **other**)<br>}))</pre> | `[]` | no | | ||||||
| | audience | The audience of the federated identity credential | `list(string)` | `["api://AzureADTokenExchange"]` | no | | ||||||
| ## Main features | ||||||
| - Create a managed identity with custom tags and location. | ||||||
| - Assign multiple RBAC roles at different scopes. | ||||||
| - Add federated credentials for GitHub Actions, Kubernetes service accounts, or custom issuers. | ||||||
| - Realistic configuration example. | ||||||
|
|
||||||
| ## Outputs | ||||||
|
|
||||||
| | Name | Description | | ||||||
| |------|-------------| | ||||||
| | <a name="output_user_assigned_identity_id"></a> [user_assigned_identity_id](#output\_user\_assigned\_identity\_id) | The ID of the User Assigned Identity. | | ||||||
| | <a name="output\_user\_assigned\_identity\_id"></a> [user\_assigned\_identity\_id](#output\\_user\\_assigned\\_identity\\_id) | The ID of the User Assigned Identity. | | ||||||
|
|
||||||
| ## Example | ||||||
| ## Complete usage example | ||||||
|
|
||||||
| ### HCL | ||||||
| ```hcl | ||||||
|
|
@@ -90,29 +73,28 @@ federated_credentials = [ | |||||
| subject = "other" | ||||||
| } | ||||||
| ] | ||||||
|
|
||||||
| ``` | ||||||
|
|
||||||
| ### Yaml | ||||||
| ### YAML | ||||||
| ```yaml | ||||||
| name: xxx | ||||||
| resource_group_name: xxx | ||||||
|
||||||
| resource_group_name: xxx | |
| resource_group: xxx |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output description # OUTPUTS SECTION User Assigned Identity is not a useful consumer-facing description and reads like a placeholder. Update the output description in the module’s outputs.tf (so terraform-docs renders it correctly) to something like: 'The ID of the User Assigned Identity.'
| | <a name="output_id"></a> [id](#output\_id) | # OUTPUTS SECTION User Assigned Identity | | |
| | <a name="output_id"></a> [id](#output\_id) | The ID of the User Assigned Identity. | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| module "azure_mi" { | ||
| source = "../../" | ||
|
|
||
| name = "example-mi" | ||
| resource_group = "example-rg" | ||
| location = "westeurope" | ||
|
|
||
| tags_from_rg = false | ||
| tags = { | ||
| environment = "dev" | ||
| } | ||
|
|
||
| rbac = [ | ||
| { | ||
| name = "example-rbac" | ||
| scope = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg" | ||
| roles = ["Reader"] | ||
| } | ||
| ] | ||
|
|
||
| access_policies = [] | ||
|
|
||
| federated_credentials = [ | ||
| { | ||
| name = "example-github" | ||
| type = "github" | ||
| organization = "example-org" | ||
| repository = "example-repo" | ||
| entity = "ref:refs/heads/main" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: example-mi | ||
| resource_group: example-rg | ||
| location: westeurope | ||
|
|
||
| tags_from_rg: false | ||
| tags: | ||
| environment: dev | ||
|
|
||
| rbac: | ||
| - name: example-rbac | ||
| scope: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg | ||
| roles: | ||
| - Reader | ||
|
|
||
| access_policies: [] | ||
|
|
||
| federated_credentials: | ||
| - name: example-github | ||
| type: github | ||
| organization: example-org | ||
| repository: example-repo | ||
| entity: ref:refs/heads/main |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ## Examples | ||
|
|
||
| For detailed examples, refer to the [module examples](https://github.com/prefapp/tfm/tree/main/modules/azure-mi/_examples): | ||
|
|
||
| - [basic](https://github.com/prefapp/tfm/tree/main/modules/azure-mi/_examples/basic) - User-assigned managed identity with basic configuration. | ||
|
|
||
| ## Resources and support | ||
|
|
||
| - [Official Azure Managed Identities documentation](https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview) | ||
| - [Terraform reference for azurerm_user_assigned_identity](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | ||
| - [Community support](https://github.com/prefapp/terraform-modules/discussions) | ||
|
|
||
| Need help? Open an issue or join the Prefapp community. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This manual Outputs section in the header conflicts with the terraform-docs autogenerated Outputs section later in the README (which lists
id). Keeping both will drift over time and is already inconsistent. Prefer removing the manual Outputs section from the custom header (or make it match the actual output names), and rely on terraform-docs for Outputs rendering.