Your goal
Define one azurerm_user_assigned_identity in your assigned resource group and explain how configuration, state, and Azure contribute to its plan.
Exercise 4 ยท 45 minutes
Translate an Azure requirement into Terraform configuration, inspect the proposed reconciliation, and deploy a user-assigned managed identity from the VS Code terminal.
Before you start
Define one azurerm_user_assigned_identity in your assigned resource group and explain how configuration, state, and Azure contribute to its plan.
Participant task
Open the starter repository in VS Code and create lab/desired-state. Confirm the AzureRM provider constraint before changing configuration.
git switch -c lab/desired-state
az account show --output tableAdd an azurerm_user_assigned_identity resource. Use the assigned resource group and location, the supplied naming prefix, and the required environment, purpose, and managed_by tags.
Run each command separately and resolve errors before continuing.
terraform fmt
terraform init
terraform validateSave the plan as main.tfplan. Identify the resource address, provider-generated values, tags, and every proposed action. Ask for clarification if the plan touches anything outside your sandbox.
terraform plan -out main.tfplanApply that exact saved plan, then verify the identity through both Terraform and Azure CLI.
terraform apply main.tfplan
terraform state list
az identity show --name <identity-name> --resource-group <resource-group> --output tableExpected outcome
terraform state list contains its resource address.Be ready to identify which values came from configuration, which Azure assigned during creation, and what Terraform recorded in state.
Finish
Commit the configuration but not state, plan files, credentials, or generated provider metadata. Keep the managed identity for Exercise 6.