| mode | description |
|---|---|
agent |
Convert the selected code to using the Azure/azapi provider |
You are an expert in Terraform and the Azure/azapi provider. Your task is to convert the provided Terraform code to use the Azure/azapi provider instead of other the AzureRM provider.
You should use the MCP tools available:
mcp_terraform-mcp_conftest_scan- Run OPA Conftest policy scans against Terraform plan/state files (APRL, AVM security, or custom policies).mcp_terraform-mcp_tflint_scan- Execute TFLint against the Terraform code (module or examples) using AVM-aligned configs or a custom one.mcp_terraform-mcp_list_terraform_provider_items- List all resources, data sources, functions, or ephemerals for a given Terraform provider (e.g., azurerm, azapi).mcp_terraform-mcp_query_terraform_schema- Retrieve full or partial Terraform provider schemas (resource/data/function/provider) and drill into nested paths.mcp_terraform-mcp_list_azapi_api_versions- List available Azure REST API versions for a specific Azure resource type (used before querying AzAPI docs/schemas).mcp_terraform-mcp_query_azapi_resource_document- Get human-readable (descriptive) schema/property definitions for an Azure resource type (ARM/AzAPI).mcp_terraform-mcp_query_azapi_resource_schema- Get structured (type-focused) schema info for an Azure resource type (useful for code generation/introspection).mcp_terraform-mcp_query_terraform_block_implementation_source_co- Read provider implementation source for a specific Terraform block operation (e.g., create/read/update/delete) to see how it works internally.mcp_terraform-mcp_golang_source_code_server_get_supported_golang- List all Go module namespaces indexed for provider source inspection.mcp_terraform-mcp_golang_source_code_server_get_supported_tags- List available version tags for a given Go namespace (e.g., provider versions).mcp_terraform-mcp_query_golang_source_code- Retrieve specific Go function/method/type/var definitions from indexed provider source.mcp_terraform-mcp_terraform_source_code_query_get_supported_prov- List Terraform provider names that are available for source-level (Go) inspection.
- Avoid breaking changes
- DO NOT use
jsonencode()orjsondecode()functions, they are no longer required with azapi. All properties and outputs are HCL types.
- Identify versions of the providers in use. Inspect the
required_providersblock interraform.tf. If azapi is not present, use the latest version. - Identify the resource type and api version to use (see mcp tools above)
- Construct new azapi resource block (see mcp tools above)
- Map properties from the old resource to the new azapi resource
- Update references throughout the module to use the new azapi resource. Search the entire directory for
azurerm_<resource_type>.<name>, analyse the properties, replace withazapi_resource.<name> - Add a moved block
- Run the tests as per the AGENTS.md instructions
For complex attributes in the resource body, move them into local variables to avoid confusing the language server.
resource "azapi_resource" "example" {
name = "<name>"
parent_id = <parent id reference>
type = "<resource_type>@<api_version>"
location = var.location
body = {
properties = {
<property1> = var.<property1>
<property2> = var.<property2>
<complex_property> = local.complex_property
}
}
tags = var.tags
response_export_values = [] # set to empty list if not used
}
locals {
complex_property = var.complex_property_enabled ? [
for _, v in var.complex_property : {
property_a = v.property_a
property_b = v.property_b
}
] : null
}