| description | applyTo |
|---|---|
Azure Verified Modules (AVM) and Terraform |
**/*.terraform, **/*.tf, **/*.tfvars, **/*.tfstate, **/*.tflint.hcl, **/*.tf.json, **/*.tfvars.json |
Azure Verified Modules (AVM) are pre-built, tested, and validated Terraform and Bicep modules that follow Azure best practices. Use these modules to create, update, or review Azure Infrastructure as Code (IaC) with confidence.
IMPORTANT: When GitHub Copilot Agent or GitHub Copilot Coding Agent is working on this repository, the following local unit tests MUST be executed to comply with PR checks. Failure to run these tests will cause PR validation failures:
PORCH_NO_TUI=1 ./avm pre-commit
git add . && git commit -m "chore: avm pre-commit"
PORCH_NO_TUI=1 ./avm pr-checkThese commands must be run before any pull request is created or updated to ensure compliance with the Azure Verified Modules standards and prevent CI/CD pipeline failures. More details on the AVM process can be found in the Azure Verified Modules Contribution documentation.
Failure to run these tests will cause PR validation failures and prevent successful merges.
- Search for "avm" + resource name
- Filter by "Partner" tag to find official AVM modules
- Example: Search "avm storage account" → filter by Partner
- Terraform Resources:
https://azure.github.io/Azure-Verified-Modules/indexes/terraform/tf-resource-modules/ - Terraform Patterns:
https://azure.github.io/Azure-Verified-Modules/indexes/terraform/tf-pattern-modules/ - Bicep Resources:
https://azure.github.io/Azure-Verified-Modules/indexes/bicep/bicep-resource-modules/ - Bicep Patterns:
https://azure.github.io/Azure-Verified-Modules/indexes/bicep/bicep-pattern-modules/
- Copy the example code from the module documentation
- Replace
source = "../../"withsource = "Azure/avm-res-{service}-{resource}/azurerm" - Add
version = "1.0.0"(use latest available) - Set
enable_telemetry = true
- Copy the Provision Instructions from module documentation
- Configure required and optional inputs
- Pin the module version
- Enable telemetry
module "storage_account" {
source = "Azure/avm-res-storage-storageaccount/azurerm"
version = "0.1.0"
enable_telemetry = true
location = "East US"
name = "mystorageaccount"
resource_group_name = "my-rg"
# Additional configuration...
}- Resource Modules:
Azure/avm-res-{service}-{resource}/azurerm- Example:
Azure/avm-res-storage-storageaccount/azurerm
- Example:
- Pattern Modules:
Azure/avm-ptn-{pattern}/azurerm- Example:
Azure/avm-ptn-aks-enterprise/azurerm
- Example:
- Utility Modules:
Azure/avm-utl-{utility}/azurerm- Example:
Azure/avm-utl-regions/azurerm
- Example:
- Use kebab-case for services and resources
- Follow Azure service names (e.g.,
storage-storageaccount,network-virtualnetwork)
- Endpoint:
https://registry.terraform.io/v1/modules/Azure/{module}/azurerm/versions - Example:
https://registry.terraform.io/v1/modules/Azure/avm-res-storage-storageaccount/azurerm/versions
- For providers: use pessimistic version constraints for minor version:
version = "~> 1.0" - For modules: Pin to specific versions:
version = "1.2.3"
- URL Pattern:
https://registry.terraform.io/modules/Azure/{module}/azurerm/latest - Example:
https://registry.terraform.io/modules/Azure/avm-res-storage-storageaccount/azurerm/latest
- URL Pattern:
https://github.com/Azure/terraform-azurerm-avm-{type}-{service}-{resource} - Examples:
- Resource:
https://github.com/Azure/terraform-azurerm-avm-res-storage-storageaccount - Pattern:
https://github.com/Azure/terraform-azurerm-avm-ptn-aks-enterprise
- Resource:
- ✅ Always pin module versions
- ✅ Start with official examples from module documentation
- ✅ Review all inputs and outputs before implementation
- ✅ Enable telemetry:
enable_telemetry = true - ✅ Use AVM utility modules for common patterns
- ✅ Always run
terraform fmtafter making changes - ✅ Always run
terraform validateafter making changes - ✅ Use meaningful variable names and descriptions
- ✅ Use snake_case
- ✅ Add proper tags and metadata
- ✅ Document complex configurations
Before creating or updating any pull request:
# Format code
terraform fmt -recursive
# Validate syntax
terraform validate
# AVM-specific validation (MANDATORY)
export PORCH_NO_TUI=1
./avm pre-commit
<commit any changes>
./avm pr-check- Deployment Guidance: Use
azure_get_deployment_best_practicestool - Service Documentation: Use
microsoft.docs.mcptool for Azure service-specific guidance - Schema Information: Use
query_azapi_resource_schema&query_azapi_resource_documentto query AzAPI resources and schemas. - Provider resources and resource schemas: Use
list_terraform_provider_items&query_terraform_schemato query azurerm resource schema.
When working with AVM repositories:
- Always check for existing modules before creating new resources
- Use the official examples as starting points
- Run all validation tests before committing
- Document any customizations or deviations from examples
module "resource_group" {
source = "Azure/avm-res-resources-resourcegroup/azurerm"
version = "0.1.0" # use latest
enable_telemetry = true
location = var.location
name = var.resource_group_name
}module "virtual_network" {
source = "Azure/avm-res-network-virtualnetwork/azurerm"
version = "0.1.0" # use latest
enable_telemetry = true
location = module.resource_group.location
name = var.vnet_name
resource_group_name = module.resource_group.name
address_space = ["10.0.0.0/16"]
}- Version Conflicts: Always check compatibility between module and provider versions
- Missing Dependencies: Ensure all required resources are created first
- Validation Failures: Run AVM validation tools before committing
- Documentation: Always refer to the latest module documentation
- AVM Documentation:
https://azure.github.io/Azure-Verified-Modules/ - GitHub Issues: Report issues in the specific module's GitHub repository
- Community: Azure Terraform Provider GitHub discussions
Before submitting any AVM-related code:
- Module version is pinned
- Telemetry is enabled
- Code is formatted (
terraform fmt) - Code is validated (
terraform validate) - AVM pre-commit checks pass (
./avm pre-commit) - AVM PR checks pass (
./avm pr-check) - Documentation is updated
- Examples are tested and working