Interview Prep/Azure/Azure DevOps, Bicep and Terraform

How do you import existing Azure resources into Terraform?

IntermediateConceptAzure DevOps, Bicep and Terraform
Answer

Use import blocks (Terraform 1.5+) and let Terraform generate config:

import {
  to = azurerm_resource_group.shop
  id = "/subscriptions/<sub>/resourceGroups/rg-shop-prod"
}
terraform plan -generate-config-out=generated.tf

The import ID is the full ARM resource ID; get it with az resource show ... --query id -o tsv. Note Azure IDs are case-sensitive in Terraform state comparisons, so copy them exactly. aztfexport can bulk-export an RG into HCL plus state.

Azure All Azure questions Roadmap: AKS & Azure DevOps

More on Azure DevOps, Bicep and Terraform