|
| 1 | +# Terraform Template - User Assigned Managed Identity |
| 2 | + |
| 3 | +Costa Rica |
| 4 | + |
| 5 | +[](https://github.com/) |
| 6 | +[brown9804](https://github.com/brown9804) |
| 7 | + |
| 8 | +Last updated: 2026-02-09 |
| 9 | + |
| 10 | +------------------------------------------ |
| 11 | + |
| 12 | +> This template contains Terraform configurations to create an Azure User Assigned Managed Identity with dependencies on a Resource Group. |
| 13 | +
|
| 14 | +<img width="650" alt="image" src="https://github.com/user-attachments/assets/8149b211-3565-4c74-b7e0-17a15d0e3f1d" /> |
| 15 | + |
| 16 | +<img width="650" alt="image" src="https://github.com/user-attachments/assets/ab38d984-bd82-46d6-afc3-e11ea5175920" /> |
| 17 | + |
| 18 | +## File Descriptions |
| 19 | + |
| 20 | +- **main.tf**: Contains the main configuration for creating the Resource Group and the User Assigned Managed Identity. |
| 21 | +- **variables.tf**: Defines the input variables used in the Terraform configuration. |
| 22 | +- **provider.tf**: Configures the Azure provider to interact with Azure resources. |
| 23 | +- **terraform.tfvars**: Provides example values for the variables defined in `variables.tf`. |
| 24 | +- **outputs.tf**: Defines outputs such as the identity resource ID, client ID, and principal ID. |
| 25 | + |
| 26 | +## Variables |
| 27 | + |
| 28 | +| Variable Name | Description | Type | Example Value | |
| 29 | +| --- | --- | --- | --- | |
| 30 | +| `resource_group_name` | The name of the Azure Resource Group to create and place the identity in. | string | `"rg-identity-security-dev"` | |
| 31 | +| `location` | The Azure region where the Resource Group (and identity) will be created. | string | `"East US"` | |
| 32 | +| `managed_identity_name` | The name of the User Assigned Managed Identity to create. | string | `"id-identity-security-dev-001"` | |
| 33 | +| `tags` | A map of tags to assign to the resources. | map(string) | `{ "env": "dev" }` | |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +1. Authenticate: |
| 38 | + |
| 39 | + ```sh |
| 40 | + az login |
| 41 | + ``` |
| 42 | + |
| 43 | +2. Ensure Azure CLI has the correct active subscription: |
| 44 | + |
| 45 | + ```sh |
| 46 | + az account show |
| 47 | + # If needed: |
| 48 | + az account set --subscription "<subscription-id-or-name>" |
| 49 | + ``` |
| 50 | + |
| 51 | +3. Initialize: |
| 52 | + |
| 53 | + ```sh |
| 54 | + terraform init -upgrade |
| 55 | + ``` |
| 56 | + |
| 57 | +4. Validate and plan: |
| 58 | + |
| 59 | + ```sh |
| 60 | + terraform validate |
| 61 | + terraform plan |
| 62 | + ``` |
| 63 | + |
| 64 | +5. Apply: |
| 65 | + |
| 66 | + ```sh |
| 67 | + terraform apply -auto-approve |
| 68 | + ``` |
| 69 | + |
| 70 | +> [!NOTES] |
| 71 | +> |
| 72 | +> - This template creates the Resource Group for you. |
| 73 | +> - A User Assigned Managed Identity can be attached to Azure resources (VMs, App Service, Functions, etc.) and granted permissions via Azure RBAC. |
| 74 | +
|
| 75 | +<!-- START BADGE --> |
| 76 | +<div align="center"> |
| 77 | + <img src="https://img.shields.io/badge/Total%20views-1646-limegreen" alt="Total views"> |
| 78 | + <p>Refresh Date: 2026-02-09</p> |
| 79 | +</div> |
| 80 | +<!-- END BADGE --> |
0 commit comments