If you cannot find guidance for what you need, please let us know via GitHub Issues 👍
Subsections of Contributing
AI-Assisted Module Development
For Module Owners
This section covers module development and maintenance scenarios and is primarily relevant for AVM module owners. If you are an end user looking to leverage AVM to develop complex solutions using AI, see AI-Assisted IaC Solution Development.
Overview
AVM module owners and members of the AVM core team can leverage GitHub Copilot and related AI capabilities to accelerate the development, maintenance, and validation of AVM Bicep modules. By embedding AVM-specific knowledge directly into the development environment, we reduce manual effort, improve consistency, and help ensure compliance with AVM specifications from the start.
The AVM core team is building a set of AI-powered assets that GitHub Copilot can use to provide AVM-aware assistance. These assets fall into several categories:
Custom Instructions: Markdown files that automatically guide GitHub Copilot’s behavior whenever it generates or reviews code, providing persistent context about the project’s baseline, such as coding standards and compliance requirements.
Custom Agents: Specialized AI personas that focus on a specific workflow (e.g., planning, implementing, or validating module changes), each with a defined scope, tools, and the ability to hand off work to other agents.
Prompt Files: Reusable, parameterized task templates that define a specific analysis or action for Copilot to perform, targeting specific modules or files.
Skills: Detailed, step-by-step workflow definitions that encode domain-specific expertise. Skill descriptions are included in the system prompt on every chat turn, but their full content is loaded into context on demand — only when the model determines relevance to the user’s request or the user explicitly invokes the skill.
The actual implementations of these assets may vary between Bicep and Terraform, and they will evolve over time as best practices emerge and capabilities mature. The AVM core team will continue adding documentation and examples as we make progress - both developing new assets from scratch and refining existing ones.
Coming Soon
Content for AI-assisted AVM Terraform module development is currently being developed and will be available soon. Stay tuned for updates!
Subsections of AI-Assisted Module Dev
AVM Bicep AI Assets
This page provides a catalog of all AI-assisted development assets available in the Bicep Registry Modules (BRM) repository. Each asset is linked to its source file for full details.
Custom Instructions
Custom instructions provide persistent, repository-wide context that shapes how GitHub Copilot generates and reviews code. They are automatically loaded by Copilot when working in the repository.
Global Instructions
Global instructions provide GitHub Copilot with an overview of the AVM Bicep repository structure, critical compliance requirements (including mandatory AVM specification adherence), tool usage guidance, module discovery methods (AVM module index, MCR, Azure Resource Reference), and schema/API version lookup procedures. This is the primary instruction file that ensures all AI-generated code aligns with AVM standards.
Skills encode complex, multi-step domain workflows into structured instructions that GitHub Copilot can follow precisely. They define prerequisites, rules, phases, and expected outputs. When the IDE starts, skill descriptions are indexed so that Copilot is aware of their existence and purpose. The full content of a skill is only loaded into the context when the user’s prompt references a topic that aligns with the skill’s described purpose.
Child Module Publishing
Source: .github/skills/avm-child-module-publishing/SKILL.md Description: Guides the end-to-end workflow for publishing a Bicep child module to the AVM public registry. Covers prerequisite verification, telemetry instrumentation, version file creation, changelog updates, parent module updates, and final validation. This skill implements the official Child Module Publishing workflow.
Note: in some cases, VS Code is not identifying the correct skill based on the above prompt. If this happens, you can try to use the follow prompt that explicitly triggers the correct skill:
Analyzes AVM Bicep modules for technical debt, including inconsistencies, documentation gaps, spelling mistakes, conflicting information, and quality issues across module files and examples. This is a read-only analysis — it does not modify any files.
Analyzes AVM Bicep modules to identify resources with outdated ARM API versions, compares them against the latest stable versions, and generates detailed implementation plans for required updates. This is a planning-only task — it does not modify any files.
/AVM-Update-module-to-latest-API-versions
AVM Terraform AI Assets
Coming Soon
Content for AI-assisted AVM Terraform module development is currently being developed and will be available soon. Stay tuned for updates!
Azure Local module testing
The shared Azure Local fixture provides a reserved environment for supported module examples. Coordinate fixture access and repository configuration with the AVM maintainers.
Bicep examples
In Azure/bicep-registry-modules, the central pr-check.yml workflow routes selected tests for modules listed as Azure Local in .reserved-test-subscriptions.json to the shared fixture. Coordinate additions to that mapping with maintainers and ensure every selected E2E test template is wired to consume the fixture:
Declare resourceGroupName; the workflow supplies a disposable per-run resource group. Do not override it with a different value.
For the cluster module, declare hciHostImageReferenceId and use it as the host image reference.
For other consumers, declare an object parameter named preparedHciEnvironment and use the needed customLocationResourceId, vSwitchName, and kubernetesVersion values in the example. If the template declares hciHostImageReferenceId, the workflow supplies that too.
The workflow checks fixture readiness, acquires a consumer lease, and passes these values as parameter overrides. It releases the lease only after cleanup is confirmed; it does not provision the fixture during the PR check.
Terraform examples
For a supported consumer repository, declare the inputs your examples need. The centrally managed terraform-module.yml E2E workflow uses AVM_AZURE_LOCAL_ENVIRONMENT_ADAPTER to map those inputs to shared environment fields and supplies the values as TF_VAR_* environment variables. Declare each mapped input in every selected example. Supported projection fields are subscriptionId, tenantId, location, imageVersionResourceId, clusterResourceId, customLocationResourceId, logicalNetworkResourceId, vSwitchName, and kubernetesVersion.
Adapter provisioning is planned for automation; coordinate its availability with AVM maintainers. Repository sync activates supported consumers after the adapter and centrally managed AVM_AZURE_LOCAL_ENVIRONMENT_LOCK configuration and permissions are available. It publishes the lock and AVM_AZURE_LOCAL_ENVIRONMENT_MODE as consumer; coordinate this activation with maintainers rather than constructing the lock yourself. Lifecycle and migration repositories retain their existing E2E path; their shared-fixture integration is not yet implemented.
Validation and end-to-end testing
Follow the Bicep contribution flow or Terraform contribution flow for local validation and the central PR checks. E2E deployments are separate from local avm pr-check; use the relevant PR labels to select required or all E2E examples.
For a manual Bicep run, open Actions > .Module - PR Check, select the module path, set runE2E to true, and leave keepResources as false. Azure Local tests require cleanup. Automatic E2E needs a prepared fixture in the reserved subscription.
Create or recreate the environment
An authorized maintainer can run Actions > .Platform - Manage reserved Azure Local environment in Azure/bicep-registry-modules. The workflow selects the single subscription tagged Azure Local in the configured test pool and fails if there are none or more than one.
Select status to inspect the fixture, or prepare to create or prepare it.
Select recreate to remove the registered fixture resource groups and rebuild the environment. This selection authorizes that destructive operation; do not use it merely to check status.
Select teardown only when the environment should be removed.
There is no user-facing mode input. The workflow uses the lifecycle lease mode for maintenance; E2E consumers use consumer mode. Check the workflow result and fixture readiness before running E2E tests.
Bicep Contribution Guide
Important
While this page describes and summarizes important aspects of contributing to AVM, it may not reference All of the shared and language specific requirements.
Therefore, this contribution guide MUST be used in conjunction with the Bicep specifications. ALL AVM modules (Resource and Pattern modules) MUST meet the respective requirements described in these specifications!
Summary
This section lists AVM’s Bicep-specific contribution guidance.
You need a GitHub account. Microsoft FTEs must use a personal GitHub account linked to their Microsoft corporate identity and join the Azure organization. External contributors can use a fork without joining the organization.
Recommended Learning
Before you start contributing to the AVM, it is highly recommended that you complete the following Microsoft Learn paths, modules & courses:
Avm.Authoring, installed from Microsoft Artifact Registry (MAR). PowerShell 7.4 or later and Microsoft.PowerShell.PSResourceGet 1.2.0 or later are required. If needed, install the latter from PowerShell Gallery and restart PowerShell:
Import-Module Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.2.0
Register-PSResourceRepository -Name MAR `
-Uri 'https://mcr.microsoft.com' `
-ApiVersion ContainerRegistry `
-Trusted
Install-PSResource -Name avm.authoring `
-Repository MAR `
-Scope CurrentUser
Import-Module Avm.Authoring
avm doctor
To update from MAR, repeat Install-PSResource -Name avm.authoring -Repository MAR -Scope CurrentUser -Reinstall and start a new PowerShell session. avm update uses PowerShell Gallery, not MAR. The module downloads and caches its pinned Bicep CLI on demand; no separate Bicep installation is needed for those commands. See initializing and updating Bicep module files.
To enhance streamlined integration during interactions with upstream repositories, GitHub Desktop will automatically configure your local git repository to use the upstream repository as a remote.
Bicep Contribution Flow
This guide covers the end-to-end contribution flow for AVM Bicep modules. Whether you are a module owner or an external contributor, the core workflow is the same; the key differences are called out using tabs below.
Video Walkthrough Available
If you are a more visual learner, you can watch the AVM Bicep Contribution Walkthrough Video below for a step-by-step guide.
External contributors without upstream write access can contribute from a fork. You do not need to configure GitHub Actions, Azure credentials, or secrets in your fork for upstream PR checks.
---
config:
nodeSpacing: 20
rankSpacing: 20
diagramPadding: 50
padding: 5
flowchart:
wrappingWidth: 300
padding: 5
layout: elk
elk:
mergeEdges: true
nodePlacementStrategy: LINEAR_SEGMENTS
---
flowchart TD
Z("1 - Fork [optional]")
click Z "#1-fork-optional"
A(2 - Branch)
click A "#2-branch"
B(3 - Implement your code change)
click B "#3-implement-your-code-change"
C(4 - Run avm pre-commit)
click C "#4-run-avm-pre-commit"
C2(5 - Run pr-check and test tiers locally)
click C2 "#5-run-pr-check-and-test-tiers-locally"
D(6 - Raise or Update PR)
click D "#6-raise-or-update-pr"
E("7 - Approve and monitor CI tests [owner]")
click E "#7-approve-and-monitor-ci-tests"
F{Tests passing?}
G(8 - Review and merge PR)
click G "#8-review-and-merge-pr"
H(9 - Automated release)
click H "#9-automated-release"
Z --> A
A --> B
B --> C
C --> C2
C2 --> D
D --> E
E --> F
F -->|no| B
F -->|yes| G
G --> H
gh repo fork Azure/bicep-registry-modules --clone
cd bicep-registry-modules
Keep your fork synchronized with upstream main before creating a branch.
Skip this step and clone the upstream repository:
git clone https://github.com/Azure/bicep-registry-modules.git
cd bicep-registry-modules
2. Branch
Create a branch from the latest upstream main in your upstream checkout or synchronized fork:
git checkout -b <your-branch-name>
3. Implement your code change
Follow the composition guidance and update the module’s source, changelog, and applicable tests. A new module requires an approved proposal before work starts.
Initialize a new module once
For an approved resource module, run this from the repository root, replacing the path with the approved module path:
Use the approved module type for a pattern or utility module. The command prompts for missing approved metadata in an interactive terminal and scaffolds missing source, metadata, version, changelog, and test files without overwriting existing files. For unattended use, provide required metadata with -InputObject. For an approved proposal without source, use the metadata-only process.
To initialize a child, set $childPath to its approved path and run:
Run the AVM commands in steps 4–5 from the module directory. AVM infers the ecosystem and module path from the current location; use explicit targeting options only to work on a different module.
Update generated files after editing
Add custom Notes to generated READMEs
Create a README.notes.md file in the module directory for custom Notes. Put only the note text in the sidecar, without a heading; the generator adds the heading. For child modules, create a separate sidecar in each child module directory. Commit each sidecar with the module changes and keep any referenced images in the module’s src directory.
avm pre-commit
This validates metadata, formats and checks Bicep, compiles main.json, and generates README.md for the module and its children. Review and commit the changes, and rerun after subsequent edits. Do not run it on a metadata-only proposal before its source exists.
5. Run pr-check and test tiers locally
After committing generated changes, run the PR checks with a clean working tree:
avm pr-check
avm pr-check validates the module and checks generated-file drift; it does not replace the shared PR checks or run deployment tests.
The following test tiers are optional local checks and run separately from avm pr-check.
Unit testing
Run authored Pester unit tests, including child modules:
avm test unit -Recurse
A missing unit suite is reported as skipped, not passed.
Local e2e testing
To list available deployment tests without Azure access:
avm test e2e -Recurse -List
To run deployment tests locally, sign in to Azure PowerShell and Azure CLI with the same account, tenant, cloud, and subscription. The command uses Azure CLI to deploy and validate Bicep templates and checks that its identity matches the Azure PowerShell context. The subscription and tenant default to the active Azure PowerShell context; pass -SubscriptionId and -TenantId only when selecting a different target.
The runner appends a unique run ID to the resource group prefix to isolate each test’s resources and cleanup scope. The default prefix is avmtest; set -ResourceGroupPrefix only when you need a custom prefix.
Resource locations are selected automatically from eligible regions. The deployment metadata location is also selected automatically and remains fixed across regional retries; set -Location only to override it.
avm test e2e -Recurse
Deployment tests can create, update, and remove Azure resources, incur costs, and register required providers or features. Additional inputs depend on the test and deployment scope; see the e2e command reference.
Run e2e tests in your fork
Prefer the local commands above. For long-running tests, external contributors can instead manually run the PR check workflow in their fork against an authorized Azure test subscription. This is separate from the upstream PR checks and does not satisfy the upstream merge gate.
Set up and run the fork workflow
Synchronize your fork with upstream main, enable GitHub Actions in the fork, and push the changes to test. Ensure the PR check workflow is present on the fork’s default branch.
Sign in to gh and az, then select your authorized Azure test subscription before running the PowerShell script below:
az account set --subscription '<test-subscription-name-or-id>'
Replace the script placeholders with your fork, a new identity name, and an Azure region. You need repository administration and permission to create a resource group, a user-assigned managed identity (UAMI), its federated credential, and a subscription role assignment.
The script creates or reuses a resource group named <identity-name>-rg, an avm-validation environment, a UAMI with GitHub OIDC federation, and a Contributor assignment on the entire test subscription. The environment gives manually dispatched workflows in your fork access to Azure, so only run workflow code you trust. It writes the three ARM_*_OVERRIDE repository variables. Contributor can modify and delete resources throughout that subscription. Use a dedicated test subscription, review the script, and confirm the target before it makes changes. Some tests need additional permissions or scopes.
The script refuses to overwrite an existing identity, override variable, or override secret. It preserves other protection settings on an existing avm-validation environment. Do not run setup concurrently. If a command fails after making changes, inspect the fork and Azure resources before cleaning up or rerunning.
$repository = '<owner>/<fork>'$identityName = '<new-identity-name>'$location = '<azure-region>'function Invoke-Gh {
& gh @args
if ($LASTEXITCODE -ne0) { throw"GitHub CLI failed with exit code $LASTEXITCODE." }
}
function Invoke-Az {
& az @args
if ($LASTEXITCODE -ne0) { throw"Azure CLI failed with exit code $LASTEXITCODE." }
}
$ErrorActionPreference = 'Stop'if (@($repository, $identityName, $location |
Where-Object { [string]::IsNullOrWhiteSpace($_) }).Count -or $repository -notmatch'^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$'-or $identityName -match'[<>]'-or $location -match'[<>]') {
throw'Replace all placeholders with literal values.'}
$repo = Invoke-Gh api "repos/$repository" | ConvertFrom-Json
if (-not $repo.fork -or $repo.parent.full_name -ne'Azure/bicep-registry-modules') {
throw'The repository must be a fork of Azure/bicep-registry-modules.'}
$actions = Invoke-Gh api "repos/$repository/actions/permissions" | ConvertFrom-Json
if (-not $actions.enabled) { throw'Enable GitHub Actions in the fork before running this script.' }
$workflow = Invoke-Gh api "repos/$repository/actions/workflows/pr-check.yml" | ConvertFrom-Json
if ($workflow.state -notin @('active', 'disabled_manually', 'disabled_inactivity')) {
throw"Unexpected PR check workflow state: $($workflow.state)"}
$oidc = Invoke-Gh api "repos/$repository/actions/oidc/customization/sub" | ConvertFrom-Json
if (-not $oidc.use_default -or-not $oidc.sub_claim_prefix) {
throw'This script requires the default GitHub OIDC subject. Configure customized subjects separately.'}
$subject = "$($oidc.sub_claim_prefix):environment:avm-validation"$account = Invoke-Az account show --output json | ConvertFrom-Json
$subscriptionId = $account.id
[void][guid]::Parse($subscriptionId)
$resourceGroup = "$identityName-rg"$cloud = Invoke-Az cloud show --query name --output tsv
if ($cloud -ne'AzureCloud') { throw'This workflow setup supports the Azure public cloud only.' }
$resourceGroupExists = Invoke-Az group exists --subscription $subscriptionId --name $resourceGroup --output tsv
if ($resourceGroupExists -notin @('true', 'false')) { throw'Unexpected resource group status.' }
if ($resourceGroupExists -eq'true') {
$identities = @(Invoke-Az identity list --subscription $subscriptionId `
--resource-group $resourceGroup --output json | ConvertFrom-Json)
if ($identities.name -contains $identityName) { throw'The identity already exists.' }
}
$names = @('ARM_CLIENT_ID_OVERRIDE', 'ARM_TENANT_ID_OVERRIDE', 'ARM_SUBSCRIPTION_ID_OVERRIDE')
$existing = @(
Invoke-Gh variable list --repo $repository --json name --jq '.[].name' Invoke-Gh secret list --repo $repository --json name --jq '.[].name')
$environments = @(Invoke-Gh api --paginate "repos/$repository/environments?per_page=100" `
--jq '.environments[].name')
$environmentExists = $environments -contains'avm-validation'if ($environmentExists) {
$existing += @(
Invoke-Gh variable list --repo $repository --env avm-validation --json name --jq '.[].name' Invoke-Gh secret list --repo $repository --env avm-validation --json name --jq '.[].name' )
}
if (@($names | Where-Object { $existing -contains $_ }).Count) {
throw'An override variable or secret already exists; review it before proceeding.'}
Write-Host "Fork: $repository; test subscription: $($account.id)"Write-Host "Create or reuse resource group $resourceGroup, create UAMI $identityName, and grant subscription-wide Contributor."if ((Read-Host 'Type CREATE to confirm this is an authorized test subscription') -cne'CREATE') {
throw'Cancelled; no changes made.'}
if ($workflow.state -ne'active') {
Invoke-Gh workflow enable pr-check.yml --repo $repository
}
Invoke-Gh api --method PUT "repos/$repository/environments/avm-validation" `
-F'deployment_branch_policy=null' | Out-Null
if ($resourceGroupExists -eq'false') {
Invoke-Az group create --subscription $subscriptionId --name $resourceGroup `
--location $location --output none
}
$identity = Invoke-Az identity create --subscription $subscriptionId `
--resource-group $resourceGroup --name $identityName --location $location `
--output json | ConvertFrom-Json
Invoke-Az identity federated-credential create --subscription $subscriptionId `
--resource-group $resourceGroup --identity-name $identityName --name 'github-avm-validation' `
--issuer 'https://token.actions.githubusercontent.com' --subject $subject `
--audiences 'api://AzureADTokenExchange' --output none
Invoke-Az role assignment create --subscription $subscriptionId `
--assignee-object-id $identity.principalId --assignee-principal-type ServicePrincipal `
--role Contributor --scope "/subscriptions/$($account.id)" --output none
Invoke-Gh variable set ARM_CLIENT_ID_OVERRIDE --repo $repository --body $identity.clientId
Invoke-Gh variable set ARM_TENANT_ID_OVERRIDE --repo $repository --body $account.tenantId
Invoke-Gh variable set ARM_SUBSCRIPTION_ID_OVERRIDE --repo $repository --body $account.id
Write-Host 'Setup complete. Run the workflow for the changes you want to test.'
The IDs are not credentials. The workflow also accepts repository secrets with the same names, which take precedence over variables. Overrides apply only to manual runs in a fork, not upstream PR runs. Do not pass credentials as workflow inputs.
In the fork, open Actions > .Module - PR Check > Run workflow. Select the version containing the changes to test, enter the module path in modulePaths, leave authoringSource as gallery and authoringRef empty, and enable runE2E. Run the workflow and inspect the checks and cleanup results. runE2E selects required and optional scenarios.
Use only a test subscription and identity you are authorized to use. Tests can create, update, and remove resources and incur costs. For test-specific inputs and fork secret limitations, see custom CI parameters.
6. Raise or Update PR
Push your branch and open a PR targeting upstream main. Follow the PR template and provide a meaningful title and description. For a new module, link the PR on its proposal issue and notify its triager or @Azure/azure-verified-modules-tooling-contributors; after merge, update the issue with a Merged comment and notify them again.
Create the PR from your fork’s branch to main in Azure/bicep-registry-modules.
Create the PR from your upstream branch to main.
7. Approve and monitor CI tests
PR validation and applicable unit and integration tests run automatically. Review their results and update your branch if checks fail. No fork workflow setup is required for these upstream checks. If a test needs environment-specific inputs, coordinate custom CI parameters with maintainers.
Open a PR early and use these checks while iterating. When the contribution is ready for deployment tests, request an e2e label; delaying those tests avoids unnecessary cloud costs and runtime.
An authorized maintainer must apply at least one of these labels to a same-repository PR to run its automatic e2e tests:
PR: Run Required E2E Tests runs the applicable required scenarios for the module class. Resource modules require defaults and waf-aligned; pattern and utility modules require defaults only. A WAF-aligned scenario is optional for pattern and utility modules.
PR: Run All E2E Tests runs the required scenarios and all optional scenarios.
Every selected scenario must pass the single Report check status merge gate. Missing required scenarios produce a warning, but existing required scenarios cannot be ignored to bypass checks. Required scenario names and semantics are defined in BCPRMNFR1 and SNFR2. Manual dispatch is a separate operator path; merge queues are not supported.
Labels do not give a fork PR access to credentials. An authorized FTE must perform the release-branch handoff so the same-repository follow-up PR can run authenticated e2e tests and satisfy the merge gate.
For an upstream PR, apply the label for the required scenarios or the label that also includes optional scenarios. Keep a label on the PR for automatic e2e testing on subsequent updates.
Running e2e for external contributions
Immediately before the handoff, an FTE must review the source code, dependencies, and workflow changes for security at the exact current PR head. Review the new head again if it changes. Authenticate the GitHub CLI (gh) as an authorized FTE with upstream access, then run:
The command cannot verify which commit was reviewed. It captures the current head and stops if it changes during the handoff. It creates a release branch from main, retargets and merges the fork PR into that branch, opens a follow-up PR to main, and labels it PR: Run Required E2E Tests. An authorized maintainer may instead use PR: Run All E2E Tests to include optional scenarios. Restrict write access to the release branch and review any later changes before E2E testing or merging the follow-up PR. Use --whatif to preview; the command does not bypass repository protections.
If the handoff fails, inspect the fork PR and release branch before recovering manually; do not blindly rerun it. If E2E tests fail after a successful handoff, the original fork PR has been merged. Open a new fork PR containing the original changes and fixes, review its current head, and perform a new handoff. Inspect the existing follow-up PR and release branch before proceeding.
8. Review and merge PR
Address review feedback and request a re-review after updates. Authors cannot approve their own PRs.
Address review comments, update your branch, and request a re-review. An eligible repository team member merges the PR when required approvals and checks pass.
A new module requires AVM core team review before merging. For ordinary changes, any eligible BRM repository team member may approve and merge under repository rules. Changes to metadata.json require metadata code-owner review.
9. Automated release
After merge, the module release workflow runs on pushes to main and can also be started manually. It discovers pending releases, checks the changelog, and creates scoped release tags. Module owners must verify both the release workflow and subsequent publication to the public Bicep registry; tag creation alone does not prove publication. Metadata-only changes must not trigger a module release.
Bicep Composition
Important
While this page describes and summarizes important aspects of the composition of AVM modules, it may not reference All of the shared and language specific requirements.
Therefore, this guide MUST be used in conjunction with the Bicep specifications. ALL AVM modules (Resource and Pattern modules) MUST meet the respective requirements described in these specifications!
Important
Before jumping on implementing your contribution, please review the AVM Module specifications, in particular the Bicep specification page, to make sure your contribution complies with the AVM module’s design and principles.
For an approved new module, run avm init from the root of the Bicep registry checkout. It creates the missing module and provider directories, metadata, Bicep source, version and changelog files, and root end-to-end test templates without overwriting existing files. For example, replace the path below with the approved resource module path:
Once you have implemented the source and tests, run avm pre-commit from the module directory to build main.json and generate the README. See initializing and updating module files for the full local workflow. To register an approved proposal without creating main.bicep, follow the metadata-only proposal guide instead.
Code Styling
This section points to conventions to be followed when developing a Bicep template.
Modules enable you to reuse code from a Bicep file in other Bicep files. As such, for resource modules they’re normally leveraged for deploying child resources (e.g., file services in a storage account), cross referenced resources (e.g., network interface in a virtual machine) or extension resources (e.g., role assignments in a key vault). Pattern modules, normally reuse resource modules combined together.
Make sure to review all specifications covering module properties and usage.
Tip
See examples in specifications BCPFR1 for resource modules and PMNFR2 for pattern modules.
Outputs
Make sure to review all specifications of Category: Inputs/Outputs within the Bicep specific pages.
This section is only relevant for contributions to resource modules.
To meet RMFR4 and RMFR5 AVM resource modules must leverage consistent interfaces for all the optional features/extension resources supported by the AVM module primary resource.
Please refer to the Bicep Interfaces page. If the primary resource of the AVM resource module you are developing supports any of the listed features/extension resources, please follow the corresponding provided Bicep schema to develop them.
Deprecation
Breaking changes are sometimes not avoidable. The impact should be kept as low as possible. A recommendation is to deprecate parameters, instead of completely removing them for a couple of versions. The Semantic Versioning sections offers information about versioning AVM modules.
In case you need to deprecate an input parameter, this sample shows you how this can be achieved.
Note
Since all modules are versioned, nothing will change for existing deployments, as the parameter usage does not change for any existing versions.
Example-Scenario
An AVM module is modified, and the parameters will change, which breaks backward compatibility.
parameters are changing to a custom type
the parameter structure is changing
backward compatibility will be maintained
Existing input parameters used to be defined as follows (reducing the examples to the minimum):
Before you begin to modify anything, it is recommended to create a new test case (e.g. deprecated), in addition to the already existing tests, to make sure that the changes are not breaking backward compatibility until you decide to finally remove the deprecated parameters (see BCPRMNFR1 - Category: Testing - Expected Test Directories for more details about the requirements).
The test should include all previously used parameters to make sure they are covered before any changes to the new parameter layout are done.
Code Changes
The new parameter structure requires a change to the used parameters and moves them to a different location and looks like:
// main.bicep:param item itemType?
type itemtype: {
name: string // the name parameter did not change properties ={
osType: 'Linux' | 'Windows'? // the new place for the osType variant: {
size: string? // the new place for the variant size }?
}
// keep these for backward compatibility in the new type @description('Optional. Note: This is a deprecated property, please use the corresponding `properties.osType` instead.')
osType: string? // the old parameter location @description('Optional. Note: This is a deprecated property, please use the corresponding `properties.variant.size` instead.')
variant: string? // the old parameter location}
The original parameter item is of type object and does not give the user any clue of what the syntax is and what is expected to be added to it. The tests could bring light into the darkness, but this is not ideal. In order to retain backward compatibility, the previously used parameters need to be added to the new type, as they would be invalid otherwise. Now that the new type is in place, some logic needs to be implemented to make sure the module can handle the different sources of data (new and old parameters).
resource<modulename>'Microsoft.xy/yz@2024-01-01' = {
name: name
properties: {
osType: item.?properties.?osType ?? item.?osType ??'Linux'// add a default here, if needed variant: {
size: item.?properties.?variant.?size ?? item.?variant
}
}
}
By choosing this order for the Coalesce operator, the new format takes precedence over the old syntax. Also note the safe-dereference ensures that no null reference exception will occure if the property has optional parameters.
The tests can now be changed to adapt the new parameter structure for the new version of the module. They will not cover the old parameter structure anymore.
Changes to modules (resource or pattern) can bei implemented in two ways.
Implement changes with backward compatibility
In this scenario, you need to make sure that the code does not break backward compatibility by:
adding new parameters
marking other parameters as deprecated
create a test case for the old usage syntax
increase the minor version number of the module (0.x)
Introduce breaking changes
The easier way to introduce a new major version requires fewer steps:
adding new parameters
create a test case for the usage
increase the major version number of the module (x.0.0)
Note
Be aware that currently no module has been released as 1.0.0 (or beyond), which lets you implement breaking changes without increasing the major version.
Advanced Topics & FAQ
Custom CI parameters
Use GitHub Actions secrets or variables to supply environment-specific inputs to your main.test.bicep end-to-end tests, such as tenant-specific object IDs or credentials. This avoids hardcoding values specific to your local or centrally managed test environment. Never commit private values to test files.
These are additional template inputs, not Azure login credentials. Upstream CI uses OIDC with the avm-validation environment and its VALIDATE_CLIENT_ID, VALIDATE_TENANT_ID, and VALIDATE_SUBSCRIPTION_ID secrets.
Forks and upstream validation
Fork PRs cannot access upstream secrets or run credentialed E2E tests directly. You can run tests manually in your fork using your own Azure test environment. Fork repository CI_* variables can supply non-sensitive test inputs, but arbitrary CI_* secrets are not forwarded through the fork workflow’s reusable-workflow boundary. Do not put sensitive values in variables; run those tests locally with secure parameters instead.
When adding a required input, ask maintainers to configure the corresponding GitHub secret or variable in the upstream environment before merging your contribution. Share the parameter name and purpose, never its private value. An authorized FTE must perform the release-branch handoff for authenticated upstream validation.
Setup
Declare the parameters in your main.test.bicep file and reference them as normal Bicep parameters. Keep an empty default for these string inputs so PSRule scans have a value for every parameter.
For example:
@description('Required. Credential supplied by the CI_MY_SECRET GitHub Actions secret.')
@secure()
param mySecret string = ''@description('Optional. Non-sensitive label used by this test.')
param deploymentLabel string = ''
An authorized maintainer can add the corresponding values under Settings > Secrets and variables > Actions in the upstream repository, or under Settings > Environments > avm-validation for environment-scoped values:
GitHub Actions name
Store as
Template parameter
Value
CI_MY_SECRET
Secret
mySecret
Set privately; do not put the value in source control or logs.
CI_DEPLOYMENT_LABEL
Variable
deploymentLabel
For example, the non-sensitive label avm-ci.
GitHub secret and variable names cannot contain hyphens. Prefer readable CI_ names for usual camelCase parameters; reserve CI__ for literal parameter names, including underscores.
With CI_, the CI strips the single prefix and removes all suffix underscores before matching. With CI__, it strips the double prefix and preserves suffix underscores. Both modes match actual declared test parameters case-insensitively and pass their canonical Bicep spelling. Only matching parameters are supplied.
These are alternative spellings; choose one name for each input:
GitHub Actions name
Matching template parameter
CI_ADMIN_MEMBERS_SECRET
adminMembersSecret
CI_ADMINMEMBERSSECRET
adminMembersSecret
CI__ADMIN_MEMBERS_SECRET
admin_members_secret, not adminMembersSecret
CI__ADMINMEMBERSSECRET
adminMembersSecret
CI___NAME
_name
Reserved name:CI_KEY_VAULT_NAME remains the existing vault selector and is excluded from template input mapping. To supply a test parameter named keyVaultName, use CI__KEYVAULTNAME.
String inputs, including secure strings, are used as supplied. For Boolean, integer, array, and object parameters (including secure objects), supply valid JSON matching the compiled template parameter type.
Protect sensitive inputs
Use GitHub secrets for private values, and variables only for clearly non-sensitive configuration. Keep @secure() on sensitive Bicep parameters. The CI converts secure strings to PowerShell SecureString values and parses secure objects into dictionaries, preserving the template’s ARM secureObject declaration. This also applies to inputs from GitHub variables. Neither @secure() nor these conversions make a GitHub variable’s stored value private.
How it works
Workflows use the resolved GitHub secrets and vars contexts. Both repository-scoped and environment-scoped values are supported; GitHub applies its own scope precedence within each context. Use the same GitHub spelling across scopes when overriding an input so GitHub can apply that scope precedence to the override.
After name resolution, values for the same template parameter are selected in this order:
Source priority comes first: a CI__ secret still beats a CI_ variable. Within one source category (secrets or variables), CI_ wins over CI__ when both resolve to the same parameter; for example, secret CI_FOO beats secret CI__FOO for foo.
Multiple aliases for the same parameter within a source category’s winning prefix remain ambiguous and fail. For example, secrets CI_ADMIN_MEMBERS_SECRET and CI_ADMINMEMBERSSECRET both resolve to adminMembersSecret through CI_; neither has priority over the other.
Names resolving to different declared parameters remain independent: CI_ADMIN_MEMBERS_SECRET supplies adminMembersSecret, while CI__ADMIN_MEMBERS_SECRET supplies admin_members_secret.
A configured empty winning value, including a CI_ value, still wins and does not trigger fallback to a lower-priority prefix or source.
The CI passes the resolved values through the PowerShell AdditionalParameters object to the applicable Test-Az*Deployment and New-Az*Deployment cmdlets. This is runtime deployment parameter injection, not source token substitution or a .bicepparam file mechanism.
Legacy Key Vault fallback
CI Key Vault support is deprecated
vars.CI_KEY_VAULT_NAME remains an optional fallback for existing setups. Using it emits a visible GitHub Actions deprecation warning, and support may be removed in a future release. Use GitHub Actions secrets or variables for new setups.
Existing setups can retain the CI_KEY_VAULT_NAME repository variable, the vault, and its CI--prefixed secrets. The legacy CI- suffix is matched literally and case-insensitively, unchanged by the GitHub naming rules. The CI identity still needs permission to list and read secrets, for example through the Key Vault Secrets User role. Matching Key Vault secrets are used only when no GitHub secret or variable supplies that parameter; keep the corresponding Bicep parameters secure.
Migrate existing inputs
Inventory the CI- secrets used by your test parameters and identify every workflow that depends on the vault. Prefer the preview-only migration helper for this inventory.
Map each source name to a readable GitHub CI_ name, or a CI__ name for literal underscores or a reserved-name conflict. For example, Key Vault secret CI-mySecret becomes GitHub secret CI_MY_SECRET, supplying mySecret.
Copy each value privately to the intended repository or environment scope. Default to a GitHub secret; choose a variable only after confirming the value is non-sensitive. Coordinate corresponding upstream inputs with the maintainers.
Confirm that all dependent workflows use the migrated inputs before removing CI_KEY_VAULT_NAME. Do not delete the vault or its secrets as part of this change without checking for other consumers.
Preview with the migration helper
Check workflow availability
The GitHub CI parameter support and migration helper were introduced in Azure/bicep-registry-modules#7339. Verify the implementation is available in your checkout and dependent workflows before applying a migration.
The Copy-CIKeyVaultSecretsToGitHub helper requires PowerShell 7.2 or later, an authenticated Az.KeyVault session, and the GitHub CLI authenticated to github.com. From a bicep-registry-modules checkout containing the helper, replace the placeholders and preview selected inputs:
For new entries, the helper generates readable names from camelCase and acronyms: CI-mySecret becomes CI_MY_SECRET, CI-deploymentLabel becomes CI_DEPLOYMENT_LABEL, and CI-managedHSMResourceId becomes CI_MANAGED_HSM_RESOURCE_ID. Literal underscores or reserved-name conflicts use CI__ spelling.
Without -Apply, the helper lists names and metadata only: it does not read secret values or change GitHub settings. -SecretName is a literal, case-insensitive allowlist of source CI- names; omitting it selects all CI- entries. -VariableName accepts either CI_ or CI__ aliases that resolve to selected source parameters explicitly confirmed as non-sensitive; all other values remain secrets. Prefer the planned readable output names, as in the example. Omit -Environment to target repository scope.
Review the preview and obtain explicit operator approval before adding -Apply to copy values. When selecting an existing destination entry of the same kind for a parameter, the helper also prefers CI_ over CI__. It skips the winning entry by default and reuses and overwrites only that entry when -Overwrite is explicitly specified. Any losing CI__ alias is left unchanged, not deleted. Ambiguity within the winning prefix and opposite-kind matches for the same parameter are blocked.
The helper never deletes entries and sends version-pinned values through standard input, not command arguments or files. Complete the workflow confirmation above before removing CI_KEY_VAULT_NAME.
Maintain approved handles in the root metadata.jsonowners array through the metadata review process. Reviewer routing uses those handles; it does not generate per-module CODEOWNERS entries. Monitor module issues and PRs, ensure compliance and timely reviews, and verify testing and publication.
Handover and adoption
For a handover, follow hot-swapping module owners: update root metadata in one change, obtain metadata code-owner approval, and ensure incoming owners have approved access. Do not remove shared access solely because one module changes owners. If no replacement is available, follow the orphaning process; to adopt an orphaned module, follow the adoption process.
Child resources are resources that exist only within the scope of another resource. For example, a virtual network subnet cannot exist without a virtual network. The subnet is a child resource of the virtual network.
In the context of AVM, particularly AVM Bicep resource modules, child modules are modules deploying child resources. They are implemented within the scope of their corresponding parent resource modules. For example, the module avm/res/network/virtual-network/subnet deploys a virtual network subnet and is a child module of its parent virtual network module avm/res/network/virtual-network.
By default, child modules are not published to the public bicep registry independently from their parents. They need to be explicitly enabled for publishing to be directly referenced from the registry.
This page covers step-by-step guidelines to publish a bicep child module.
Important
The child module publishing process is currently in a pilot/preview phase. This means it may not be as smooth as the general module publishing.
The core team is currently working on additional automation, with the goal of improving efficiency in addressing child module publishing requests.
Note
Child module publishing currently only applies to resource modules.
Supporting child module publishing for other module categories, such as pattern and utility modules, is not planned at this time.
Quick guide
Use this section for a fast overview on how to publish a child module. For a step-by-step explanation with detailed instructions, refer to the following sections.
Implement the required changes in a branch. Microsoft FTEs must use the upstream repository; external contributors may work in a fork:
Allowed list: Add the child module path to allowed-child-modules in the publishing allowed list if it is not already present.
Child module template: Ensure the child’s metadata.json contains its assigned telemetry prefix alongside main.bicep, then add the enableTelemetry parameter and avmTelemetry deployment.
Parent module template: In the main.bicep template of the child module direct parent, add a enableReferencedModulesTelemetry variable with a value of false, and pass it as the enableTelemetry value down to the child module deployment.
Version: Add the version.json file to the child module folder and set version to 0.1.
Changelog: Add a new CHANGELOG.md file to the child module folder and update the changelog of all its versioned parents with a new patch version, up to the top-level parent.
Generate module artifacts: Run avm pre-commit on the top-level parent module. It processes that module and its descendants, updating their compiled templates and READMEs. Test your changes and raise a PR.
Prerequisites
Before jumping into the implementation, make sure the following prerequisites are in place:
Please understand the difference between publishing an existing child module and extending a parent module with a not yet implemented child module functionality.
The Bicep Child Module Proposal issue primarily intends to cover the former, i.e. to publish a child module already existing in the BRM (Bicep Registry Modules) repository source code. However, the same issue allows also to request the development of the child module functionality, although the best way to address new functionality is to raise a feature request via the the AVM Module issue.
Telemetry ID prefix assigned
Follow the below steps to check the child module telemetry ID prefix.
Note
If the Bicep Child Module Proposal issue was just created, please allow a few days for the telemetry ID prefix to be assigned before reaching out.
Check telemetryIdPrefix in the child’s own metadata.json and keep it consistent with the child module source. Record only the assigned identifier through metadata review. Ownership is inherited from the root.
You can also look up the assigned prefix in the published index:
Search for the child module name in the ModuleName field.
Verify if the corresponding value exists in the TelemetryIdPrefix field. Note down the value as you will need it in the implementation phase.
If not found, please reach out to the core team, mentioning the @Azure/azure-verified-modules-tooling-contributors via the Bicep Child Module Proposal issue.
If the identifier is missing or conflicts with the index, ask the core team to resolve it. Do not invent an identifier or copy the parent’s prefix.
Module registered in the MAR-file
Ensure that the child module is registered in the MAR file. If not, please reach out to the core team, mentioning the @Azure/azure-verified-modules-tooling-contributors via the Bicep Child Module Proposal issue.
Metadata approval does not replace MAR registration or approval to publish the child module.
Note
The MAR-file can only be accessed by Microsoft FTEs. If you are missing access, please reach out to the parent module owner for help.
Implementation
The quickest way to get the child module published is to enable it yourself, contributing via a pull request to the BRM repository.
Note
Publishing a child module does not change the folder hierarchy of the parent and child modules. The child module remains in its existing location within the parent module’s folder structure. No files or folders need to be moved or reorganized.
Please follow the steps below:
Add the child module path to the allowed-child-modules array in the publishing allowed list, keeping alphabetical order. Validation requires a child module with a version.json file to be listed.
Update the child module main.bicep template to support telemetry, as per SFR4, SFR3 and BCPFR4
Add the enableTelemetry parameter with a default value of true. Place it as the last param declaration, immediately before the first var declaration.
Add the avmTelemetry deployment, referencing the template below. Ensure the child’s metadata.json exists alongside main.bicep before compiling and contains its assigned telemetryIdPrefix. Load only that property instead of hardcoding the prefix.
Update the main.bicep template of the child module direct parent, as per BCPFR7.
Add the enableReferencedModulesTelemetry variable with a default value of false. Place it as the last var declaration, immediately before the first resource declaration.
var enableReferencedModulesTelemetry = false
Pass the enableReferencedModulesTelemetry variable as the enableTelemetry value down to the child module deployment.
enableTelemetry: enableReferencedModulesTelemetry
Add the version.json file to the child module folder and set version to 0.1.
Add a new CHANGELOG.md file to the child module folder, with the following sample content. Make sure to replace the <avm/res/path/to/child-module> placeholder with the name of the child module.
# Changelog
The latest version of the changelog can be found [here](https://github.com/Azure/bicep-registry-modules/blob/main/<avm/res/path/to/child-module>/CHANGELOG.md).
## 0.1.0
### Changes
- Initial version
### Breaking Changes
- None
Check the list of affected modules. Update the changelog of all the affected modules with a version.json. Add a new patch version for each. Refer below for an example content section:
Run avm pre-commit on the top-level parent module to process the entire module family:
cd avm/res/storage/storage-account
avm pre-commit
Raise a PR and verify the shared checks. An authorized maintainer must apply an E2E label to run deployment tests. For an external fork PR, an authorized FTE must perform the release-branch handoff.
Note
Existing tests for the parent module do not need to be updated when publishing a child module. The changes required for child module publishing (telemetry support, version file, and changelogs) do not affect the module’s test cases.
Tip
Reference This pull request as an example for proposing a child module for publishing.
Contribution Q&A
Tip
Check out the FAQ for more answers to common questions about the AVM initiative in general.
Proposing a module
Who can propose a new module and where can I submit a new module proposal / request?
Everyone can propose a module
To propose a new module, simply create an issue/complete the form here.
Can I just propose / create any module?
For example, can I propose one for managed disks or NICs or diagnostic settings? What about patterns?
No, you cannot propose or create just any module. You can only propose modules that are aligned with requirements documented in the module specifications section.
Below, we provide some guidance on what modules you can / cannot propose.
Resource modules: resource modules have bring extra value to the end user (can’t just be simple wrappers) and MUST mapped 1:1 to RPs (resource providers) and top level resources. You MUST follow the module specifications and your modules SHOULD be WAF aligned.
Good examples:
Virtual machine: the VM module is highly complex and therefore, it brings extra value to the end user by providing a wide variety of features (e.g., diagnostics, RBAC, domain join, disk encryption, backup and more).
Storage account: even though, this module is mainly built around one RP, it brings extra value by providing easy access to its child resources, such as file/table/queue services, as well as additional standard interfaces (e.g., diagnostics, RBAC, encryption, firewall, etc.).
Bad examples:
NIC or Public IP (PIP) module: these would be simple wrappers around the NIC/PIP resource and wouldn’t bring any extra value. NICs and PIPs SHOULD be surfaced as part of the VM module (or any other primary resources that require them).
Diagnostic settings: these are too low-level “sub resources”, and highly dependent on their “primary resource’s” RP defined as “interfaces” and therefore MUST be used as part of a resource module holding a primary resource - see Diagnostic Settings documentation about the correct implementation.
Pattern modules: In case of pattern modules, ideally you should start from architectural patterns, published in the Azure Architecture Center, and build your pattern module by leveraging resource modules that are required to implement the pattern. AVM does not provide architectural guidance on how you should design your pattern, but you MUST follow the module specifications and your modules SHOULD be WAF aligned.
Good examples:
Landing zone accelerators for N-tier web application; AKS cluster; SAP: there are numerous examples for these architectures in Azure Architecture Center that already have baked in guidance / smart defaults that are WAF Aligned, therefore these are good candidates for pattern modules. Module owners MAY leverage resource modules to implement the pattern.
Hub and spoke topology: it’s a common pattern that is used by many customers and there are great examples available through Azure Architecture Center, as well as Azure Landing Zones. Also a good candidate for a pattern module.
Bad examples:
A pair of Virtual machines: being a simple wrapper, this solution wouldn’t bring any extra value as it doesn’t provide a complete solution.
Key Vault that deploys automatically generated secrets: this is aligned with the definition of a resource modules, therefore it should be categorized as such.
Where do I need to go to make sure the module I’d like to propose is not already in the works?
The AVM core team maintains the list of Bicep and Terraform modules and tracks the status of each module. Based on this list, you can check if the module you’d like to build is already in the works (e.g., it’s being worked on in a feature branch but hasn’t been published yet).
To see the formatted lists with additional information, please visit the AVM Module Indexes page.
I need a new module but I cannot own/author it for various reasons, what should I do?
You sign up to be a module owner (and optionally, you can find additional contributors to help you).
You find / request someone else to be the module owner (and optionally, you can be a contributor).
You propose a module and wait until the AVM core team finds a module owner for you (who then can optionally leverage the help of additional contributors).
As these options are increasingly more time consuming, we recommend you to start with considering option 1 and only if you cannot own the module, should you move to option 2 and then 3.
How long will it take for someone to respond and a module to be created/updated and published?
AVM does not provide fixed response or delivery targets for existing modules or new module proposals. The AVM Core Team improves the automation that module owners use to create and publish modules.
Beside of providing program level governance, the AVM core team is mainly responsible for defining the module specifications, providing tooling (such as test frameworks and pipelines), guidance and support to module owners, as well as facilitating the creation of new modules by maintaining the module catalog and identifying volunteers for owning the modules. However, modules will be created and maintained by a broader community of module owners.
How do I let the AVM team know I really need an AVM module to unblock me / my project / my company?
If you’re an external user, you can propose a module here and provide as much context as possible under the “Module Details” section (e.g., why do you need the module, what’s the business impact of not having it, etc.).
If you’re a Microsoft employee and have already proposed a module here, you can reach out to the AVM core team directly via Teams to provide more details internally.
The AVM core team will then triage the request and get back to you with next steps. You can accelerate the process of creating the module by volunteering to be a module owner.
How will the AVM module index (catalog) be updated?
Submit module details and ownership changes to the module repository’s metadata.json through the metadata review process. Ownership is maintained in the root file and requires approval from either metadata code-owner team.
A catalog sync then regenerates the indexes and publishes them automatically every four hours, so a merged metadata change normally appears in the published index within about four hours.
For deprecation, follow the retirement process. The catalog derives Deprecated from Bicep’s DEPRECATED.md or Terraform’s repository archived flag.
Developing a module
Who is developing a modules?
Every module has an owner that is responsible for module development and maintenance. One owner can own one or multiple modules. An owner can develop modules alone or lead a team that will develop a module. If you want to join a team and to contribute on specific module, please contact module owner.
At this moment, only Microsoft FTEs can be module owners.
What do I need so I can start developing a module?
Feel free to reach out to the AVM Core team in case that additional help is needed.
What do I do about existing modules that are available doing a similar thing to my module that I am proposing to develop and release?
As part of the Module Proposal process, the AVM core team will work with you to triage your proposal. We also want to make sure that no similar existing modules from known Microsoft projects are already on their way to be migrated to AVM.
If there aren’t any, then you can proceed with developing your module from scratch once given approval to proceed by the AVM core team.
However, if there are existing modules from Microsoft projects we would invite you to help us complete the migration to AVM of this module; this may also entail working with the existing module owner/team.
For existing modules that may not be directly owned and developed by Microsoft or their employees you should first review the license applied to the GitHub repository hosting the module and understand its terms and conditions. More information on GitHub repositories and licenses can be found here in Licensing a repository Most modules will use a license that will allow you to take inspiration and copy all or parts from the module source code. However, to confirm, you should always check the license and any conditions you may have to meet by doing this.
What are the mandatory labels that needs to be used while managing issues, pull requests and discussions on GitHub repositories where module are held?
Where module will live? Do I need to create separate repo or to place it in specific folder?
Bicep
For Bicep, both Resource and Pattern, AVM Modules will be homed in the Azure/bicep-registry-modules repository and live within an avm directory that will be located at the root of the repository.
Microsoft FTE module owners create a branch in the upstream Azure/bicep-registry-modules repository; they must not fork it. External contributors without write access may contribute from a fork and open a PR to upstream main; an authorized FTE must perform the release-branch handoff for authenticated validation. See the Bicep contribution flow and the directory and file structure.
Terraform
Each Terraform AVM module will have its own GitHub Repository in the Azure GitHub Organization. This repo will be created by the Module Owners and the AVM Core team collaboratively, including the configuration of permissions. To read more about how to start, navigate to Terraform AVM contribution guide.
I get the error ‘The repository ********** already exists on this account’ when I try to create a new repository, what should I do?
If you get this error, it means that the repository already exists in the Azure GitHub Organization. This can happen if someone has already created a repository with the same name in the past and then archived it.
To determine if this is the case you’ll need to navigate to the Microsoft Open Source Management Portal, then search for the repository name you are trying to create. Click on the repository and you will find the owner. Reach out the owner to ask them to transfer the repo to you or delete it. You’ll want them to delete it if it was not created from the template.
Where can I test my module during development?
During initial module development module owners/developers need to use your own environment (Azure subscriptions) to test module. In later phase, during publishing process, we will conduct automated test that will use AVM dedicated environment.
Updating and managing a module
I’m already using a module today, but its missing a feature, what should I do?
You should use GitHub issues to propose changes or improvements for specific module. Issue request will be routed to module owner that MUST respond to logged issues as per the defined support statement. In case that module currently don’t have owner, AVM Core Team will handle request.
I am using module without owner. What will happened if I need update?
AVM core team will work to assign owner for every module, but it can happen during a time that there are modules without owner. To volunteer, comment on the module’s orphaned module issue and follow the adoption process. At this moment, only Microsoft FTEs can be module owners. Add approved owners through a pull request to the root metadata file and complete access approval separately.
How is module support triage automated?
The GitHub Policy Service tracks issues created in module repositories. It applies triage and escalation workflows that support the Module Support statement.
Module Metadata
Maintain a module’s details and ownership in metadata.json in its source repository. Submit changes through the review process below.
Find the correct file
Language
Root module metadata
Bicep
avm/{res,ptn,utl}/{group}/{module}/metadata.json in Azure/bicep-registry-modules. Use the existing module’s actual path.
Terraform
metadata.json at the root of the module’s own repository. Find that repository through the module indexes.
Child modules have reduced metadata.json files in their own folders. They inherit ownership from the root module, including when nested more than one level deep. Change owners only in the root file; child files must not contain owners.
Use the existing file as your starting point and preserve unrelated values. If metadata or an assigned value is missing, ask the AVM core team to confirm the required values.
Create metadata.json when scaffolding a new module
Every new Bicep or Terraform root module, and every new child module or submodule, MUST have a valid metadata.json created as part of scaffolding, not added later.
Root modules get the full metadata shape, including the owners array.
Child modules and submodules get the reduced, inherited-owner shape described above; they must not contain owners.
Use avm init from the Avm.Authoring PowerShell module for one-time initialization. Follow the linked instructions to register MAR and install the module. Specify -Ecosystem (bicep or terraform) and -ModuleType (resource, pattern, or utility). In an interactive terminal, the command prompts for missing required metadata fields; enter only approved values. For unattended runs, provide all required fields through -InputObject, or initialization fails rather than guessing them. The command supplies the required $schema URI, validates the metadata, and does not overwrite an existing file. Terraform child module initialization (-ChildModule) creates only metadata.json; add Terraform source files separately.
Run with -WhatIf first, then without it to write the file. Add -ChildModule and omit owners for a child or submodule. -UpdateSource applies matching Bicep source literals and is not valid for Terraform.
Validate an existing file with avm metadata validate, or inspect one with avm metadata show.
Approved modules may carry metadata.json before their source exists. The catalog treats a metadata-only module as Proposed until it is published.
Create only metadata for an approved Bicep proposal
After the AVM core team approves a Bicep module proposal, you can add its root metadata.json before main.bicep exists. First install Avm.Authoring from MAR. In PowerShell 7, run this example from the root of Azure/bicep-registry-modules, replacing the path with the approved module path.
avm init prompts for the approved display name, description, ARM resource type (canonicalType), and root owners if they are not supplied. It generates the Bicep telemetryIdPrefix from cryptographically secure random bytes: 46d3xbcp.res. followed by seven lowercase hexadecimal characters. It checks for collisions with current and historical identifiers from the published module catalog and local module metadata. If the catalog is unavailable, it warns and continues with the local inventory; check against the latest catalog during review because generation does not reserve the prefix globally.
With -Proposed, the command creates the target directory if needed and writes only metadata.json; it does not create main.bicep, main.json, or version files. An existing metadata.json is never overwritten. Once merged, the module stays Proposed in the catalog until publication.
For a pattern or utility module, use the corresponding -ModuleType pattern or utility and its approved canonicalType taxonomy. For a child module, add -ChildModule; ownership is inherited from its root, so do not supply owners. See the helper submodule rules where applicable.
Fields you can maintain
The versioned schema referenced by the required $schema URI defines the supported fields.
Field
Guidance
$schema
Keep the required versioned schema URI. It identifies the module metadata schema.
moduleDisplayName, moduleDescription
Maintain the module’s curated display name and description. In Bicep, these values are independent of the metadata name and metadata description literals in main.bicep; neither needs to match its source counterpart.
canonicalType
The real ARM resource type, or the approved pattern/utility taxonomy. Helper submodules use helper.
owners
Root only: a flat array of strings containing every approved owner. Use bare GitHub handles for individuals and qualified handles such as @Azure/team-name for approved existing teams.
telemetryIdPrefix
Current Bicep prefixes must use 46d3xbcp.<kind>.<seven lowercase hexadecimal characters> (20 characters), where <kind> is res, ptn, or utl. Generate one for an approved new module; do not generate a replacement as part of an ownership or descriptive edit.
alternativeTelemetryIdPrefixes
For Bicep, retain all previously assigned prefixes here when the current prefix changes, in the same root or child metadata.json. These historical identifiers are not used in deployment names.
alternativeNames, comments
Optional root-module aliases and notes. These are public metadata.
Pattern and utility canonicalType values can have one or more segments, such as naming for avm-utl-naming. Preserve the module’s approved mapping. Resource modules and non-helper resource children use their actual ARM resource type.
Module identity and parent relationships come from the repository layout. Changing moduleDisplayName does not rename a module or move its repository.
Helper submodules
Helper submodules use the exact "canonicalType": "helper" marker with the required $schema, moduleDisplayName, and moduleDescription. Ownership is inherited from the root. Use this marker only for helper children, not root modules or resource children.
Helper telemetry is optional; any supplied telemetryIdPrefix must pass validation. Helpers appear in the JSON catalog, not in the CSV indexes.
Terraform submodules are excluded from the CSV indexes entirely, not only helpers. Bicep child modules still have their own CSV rows, and the ParentModule column names the family root rather than the immediate parent.
Submit and review a change
Agree the change with the current owners and the AVM core team. For ownership changes, retain the eligibility checks, incoming owners’ written consent, and handover requirements in the owner-change process.
Edit the relevant metadata.json on a branch or in your fork of the module repository. Preserve all owners and other values that are not part of the agreed change.
Validate metadata using the repository’s approved tooling and satisfy its required reviews before merging. Approval from an eligible member of either team satisfies metadata code-owner review; approval from both teams is not required. Being listed in the module’s owners array does not by itself authorize someone to approve. Any code changes in the same pull request still need their normal code review and tests.
The next scheduled catalog sync publishes the merged metadata change. Do not edit the generated CSV or JSON output or request a separate index update.
Metadata-only changes must not trigger a module release. Do not change version files or create a release just to update owners or other metadata. Changing moduleDescription does not require changing the Bicep metadata description literal: they serve different purposes. If a Bicep source literal itself needs correction, follow normal source validation and release rules rather than treating it as metadata-only.
In Azure/bicep-registry-modules, the root owners array controls reviewer notifications, including for child modules. It does not generate per-module CODEOWNERS entries or require a module owner’s approval for ordinary code changes. An ownerless module is routed to @Azure/azure-verified-modules-module-owners for review. The final metadata.json rule in CODEOWNERS still protects metadata changes with the two metadata code-owner teams; an eligible member of either team can approve.
Editing metadata does not grant or revoke repository permissions, create teams, change identities, or provision Azure access. Every incoming owner still needs the separate access approval described in SNFR20. Do not remove shared access solely because someone stops owning one module.
Ownership changes
Add, remove, or transfer owners
Update the owners array in the root metadata file. Add the approved incoming handles and remove only the departing handles. Keep every continuing individual or team owner.
For a direct transfer, follow hot swapping module owners and make the outgoing and incoming owner changes together, so the module does not pass through an unowned state. Do not reopen a closed module proposal.
In the root metadata file, set "owners": [], removing all individual and team handles from the array. Keep the remaining metadata intact. A published, non-deprecated module with no owners is shown as Orphaned. See how module status is calculated.
No ORPHANED.md file, manual README.md notice, or README regeneration is required for orphaning or adoption in either language. These are metadata-only ownership changes, not module releases.
Adopt an orphaned module
Follow when a new owner is identified. After eligibility and consent are confirmed, add the approved incoming handles to the root metadata’s owners array and obtain approval from either metadata code-owner team.
Complete the separate access approval before closing the ownership issue. Adding owners does not revive a deprecated module.
Catalog updates
The catalog sync runs on a four-hourly schedule (01:33, 05:33, 09:33, 13:33, 17:33, and 21:33 UTC). Each scheduled run collects metadata from the module repositories, regenerates the six CSV indexes and v1/modules.json, and publishes them to the module indexes and CSV downloads automatically. A merged metadata change therefore appears in the published index within about four hours, without a separate request to the AVM core team.
The generated outputs are not the source of truth. Propose corrections in the module’s metadata.json rather than editing generated CSV or JSON files; the next scheduled run overwrites them. The AVM core team owns the catalog tooling and handles any run that is held back by a safeguard.
CSV owner columns show the first two individuals. Root metadata and the JSON catalog contain the full owner list.
Module status
The catalog calculates ModuleStatus from evidence, not from an authored field. The first matching condition wins:
Condition
Status
Deprecation evidence, or an existing Deprecated status in the CSV
Deprecated
Not published in the registry
Proposed
Published with no owners
Orphaned
Published with at least one owner
Available
A module that is both deprecated and unpublished is omitted from the CSV indexes and v1/modules.json altogether, and the run warns that its unused source or repository can be deleted.
Related processes
New proposals: Follow the module proposal and approval process. The approved name, description, and owners are agreed in the proposal issue. Once approved, metadata.json may be created before the module source exists; the module stays Proposed until it is published. Do not create metadata for a module that has not been approved.
Publication: Registry publication is required before a module is available. A metadata change does not publish a module.
Deprecation: Follow the deprecation process, including approval, notices, and language-specific retirement steps. The catalog derives deprecation from Bicep’s DEPRECATED.md or the Terraform repository’s archived flag, not an authored metadata status.
A Bicep marker applies to its module and descendants, not its parent or siblings. Terraform archival applies to every module entry in that repository. Changing owners does not deprecate or reactivate a module. A module that is deprecated before it was ever published is removed from the indexes rather than listed as Deprecated.
This page provides an overview of the contribution process for AVM modules.
New Module Proposal & Creation
Important
Each AVM module MUST have a Module Proposal issue created and approved by the AVM core team before it can be created/migrated!
Note
Record approved details in the proposal issue. Once the module is approved, maintain those details in its metadata.json through the metadata review process. Metadata may be created before the module source exists.
---
config:
nodeSpacing: 20
rankSpacing: 20
diagramPadding: 5
padding: 5
useWidth: 100
flowchart:
wrappingWidth: 400
padding: 5
---
flowchart TD
ModuleIdea[Consumer has an idea for a new AVM Module] -->CheckIndex(Check AVM Module Indexes)
click CheckIndex "/Azure-Verified-Modules/indexes/"
CheckIndex -->IndexExistenceCheck{Is the module<br>in the index?}
IndexExistenceCheck -->|No|A
IndexExistenceCheck -->|Yes|EndExistenceCheck(Review existing/proposed AVM module)
EndExistenceCheck -->OrphanedCheck{ Is the module<br>orphaned? }
click OrphanedCheck "/Azure-Verified-Modules/specs/shared/module-lifecycle/#3-orphaned-modules"
OrphanedCheck -->|No|ContactOwner[Contact module owner,<br> via GitHub issues on the related <br>repo, to discuss enhancements/<br>bugs/opportunities to contribute etc.]
OrphanedCheck -->|Yes|OrphanOwnerYes(Locate the related issue <br> and comment on:<br> - A feature/enhancement suggestion <br> - Indicating you wish to become the owner)
click OrphanOwnerYes "/Azure-Verified-Modules/specs/shared/module-lifecycle/#3-orphaned-modules"
OrphanOwnerYes -->B
A[[ Create Module Proposal ]] -->|GitHub Issue/Form Submitted| B{ AVM Core Team<br>Triage }
click A "https://aka.ms/avm/moduleproposal"
click B "/Azure-Verified-Modules/help-support/issue-triage/avm-issue-triage/#avm-core-team-triage-explained"
B -->|Module Approved for Creation| C[["Module Owner(s) Identified & assigned to GitHub issue/proposal" ]]
B -->|Module Rejected| D(Issue closed with reasoning)
C -->E[[ Approved proposal recorded by AVM Core Team]]
click E "/Azure-Verified-Modules/help-support/issue-triage/avm-issue-triage/#module-proposal-triage"
E -->E1[[Repo/Directory Created following the <br> Contribution Guide ]]
click E1 "/Azure-Verified-Modules/contributing/"
E1 -->F("Module Developed by Owner(s) & their Contributors")
F -->E2[[ Module metadata submitted and reviewed ]]
click E2 "/Azure-Verified-Modules/contributing/module-metadata/"
E2 -->G[[ Module & AVM Compliance Tests ]]
click G "/Azure-Verified-Modules/spec/SNFR3"
G -->|Tests Fail|I(Modules/Tests Fixed <br> To Make Them Pass)
I -->F
G -->|Tests Pass|J[[Version 0.1.0 created]]
J -->K[[Publish to Bicep/Terraform Registry]]
K -->L(Take Feedback from v0.1.0 Consumers)
L -->M{Anything<br>to be resolved <br> before 1.0.0<br>release? }
click M "/Azure-Verified-Modules/contributing/process/#avm-preview-notice"
M -->|Yes|FixPreV1("Module feedback incorporated by Owner(s) & their Contributors")
FixPreV1 -->PreV1Tests[[Self & AVM Module Tests]]
PreV1Tests -->|Tests Fail|PreV1TestsFix(Modules/Tests Fixed To Make Them Pass)
PreV1TestsFix -->N
M -->|No|N[[Publish 1.0.0 Release]]
N -->O[[Publish to IaC Registry]]
O -->P[[ Module BAU Starts ]]
click P "/Azure-Verified-Modules/help-support/module-support/"
Provide details for module proposals
When proposing a module, please include the information in the description that is mentioned for the triage process here:
The AVM framework continues to evolve, and several elements, such as Continuous Integration (CI) processes, module specifications and corresponding specification‑validation coverage, are not yet fully implemented. Hence, modules MUST NOT be published at version 1.0.0 or higher at this time.
All module MUST be published as a 0.x.y minor version (e.g., 0.1.0, 0.1.1, 0.2.0, etc.) until the AVM team provides guidance that publishing v1.0.0 is allowed.
The example and test policies remain applicable while modules are pre-v1. Resource modules require executable defaults and waf-aligned scenarios; pattern and utility modules require executable defaults only. Required scenarios must not be placeholders or ignored. A folder named waf-aligned does not prove semantic WAF compliance.
The Terraform composition check is advisory before v1 and may report warnings rather than block publishing or merging. It does not change the existing normative requirements or add a release gate; any enforcement behavior depends on the Tools rollout.
However, it is important to note that this DOES NOT mean that the modules cannot be consumed and utilized. They CAN be leveraged in all types of environments (dev, test, prod etc.). Consumers can treat them just like any other IaC module and raise issues or feature requests against them as they learn from the usage of the module. Consumers should also read the release notes for each version, if considering updating to a more recent version of a module to see if there are any considerations or breaking changes etc.
Module Owner Has Issue/Is Blocked/Has A Request
In the event that a module owner has an issue or is blocked due to specific AVM missing guidance, test environments, permission requirements, etc. they should follow the below steps:
Tip
Common issues/blockers/asks/request are:
Subscription level features
Resource Provider Registration
Preview Services Enablement
Entra ID (formerly Azure Active Directory) configuration (SPN creation, etc.)
Please note for module specific issues, these should be logged in the module’s source repository, not the AVM repository.
Terraform Contribution Guide
Important
Every new AVM Terraform module MUST use AzAPI for all control-plane resources and supported data-plane operations. AzureRM is permitted only for a specific unsupported data-plane/non-ARM API operation under the narrow TFFR3 exception. This rule applies to the root module, submodules, examples, end-to-end tests, Terraform tests, fixtures, and documentation snippets; supporting control-plane resources in every surface must use AzAPI.
While this page describes and summarizes important aspects of contributing to AVM, it only references some of the shared and language specific requirements.
Therefore, this contribution guide MUST be used in conjunction with the Terraform specifications. All AVM modules MUST meet the applicable requirements in those specifications.
Summary
This section lists AVM’s Terraform-specific contribution guidance.
AVM TFLint Rules — custom rules, their requirements, and supported overrides
Repository Setup — creating a new module repository (owners only)
Subsections of Terraform Modules
Prerequisites
GitHub Account
To contribute, you need a GitHub account. If you are a Microsoft employee, your account must be linked to your corporate identity and you must be a member of the Azure organization.
Module Owner Access (Microsoft FTEs only)
Note
This step is only required if you are (or are becoming) a Terraform module owner. External contributors and one-off contributors do not need this access.
Access for Terraform module owners is granted via the Azure Verified Modules (AVM) Module Contributors Entra access package. Request access here:
Once approved, you will be added to the azure-verified-modules-module-contributors Entra group, which is the source of truth for who is authorized to own and approve changes on AVM Terraform module repositories.
Tip
Until your access request is approved, you can continue to contribute by using JIT elevation and by raising PRs that are approved by an existing module owner.
Required Tooling
Tip
Avm.Authoring supports Windows, Linux, and macOS. Use PowerShell 7.4 or later on every platform.
Import-Module Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.2.0
Register-PSResourceRepository -Name MAR `
-Uri 'https://mcr.microsoft.com' `
-ApiVersion ContainerRegistry `
-Trusted
Install-PSResource -Name avm.authoring `
-Repository MAR `
-Scope CurrentUser
Import-Module Avm.Authoring
avm doctor
Use lowercase avm.authoring for the registry lookup; no Azure sign-in is needed. To update from MAR, repeat Install-PSResource with -Reinstall, then start a new PowerShell session. avm update still uses PowerShell Gallery. The module downloads, verifies, and caches its managed tools, including Terraform, on demand. Run avm doctor --install to preload every supported tool. Docker and Podman are not required.
This guide covers the end-to-end contribution flow for AVM Terraform modules. Whether you are a module owner or an external contributor, the core workflow is the same — the key differences are called out using tabs below.
Important
Every new AVM Terraform module MUST use AzAPI for every control-plane resource and supported data-plane operation. AzureRM is permitted only for a specific unsupported data-plane/non-ARM API operation under the narrow TFFR3 exception. The same rule applies to submodules, examples, end-to-end tests, Terraform tests, fixtures, and documentation snippets.
This guide MUST be used in conjunction with the Terraform specifications. All AVM modules must meet the requirements described in those specifications.
Prerequisites
Install PowerShell 7.4 or later, start pwsh, and follow the prerequisites to upgrade PSResourceGet and register Microsoft Artifact Registry (MAR). Then install the Avm.Authoring module:
Run avm with no arguments to list the supported verbs, then verify the installed version and diagnose your local environment:
avm
avm version
avm doctor
To update from MAR, repeat the install command with -Reinstall, then start a new PowerShell session; avm update still uses PowerShell Gallery. Avm.Authoring downloads, verifies, and caches Terraform, TFLint, terraform-docs, Conftest, and mapotf on demand. Docker or Podman is not required. You can inspect or manage the tool cache:
avm tool list
avm tool which terraform
avm tool install terraform
avm doctor --install
Warning
The local Avm.Authoring migration and the centrally managed CI workflow rollout are separate changes. The CI guidance below applies after the updated workflow is rolled out. Do not pre-emptively rename required checks; use the exact Report check status context reported by the updated workflow.
Overview
---
config:
nodeSpacing: 20
rankSpacing: 20
diagramPadding: 50
padding: 5
flowchart:
wrappingWidth: 300
padding: 5
layout: elk
elk:
mergeEdges: true
nodePlacementStrategy: LINEAR_SEGMENTS
---
flowchart TD
Z("1 - Fork [optional]")
click Z "#1-fork-optional"
A(2 - Branch)
click A "#2-branch"
B(3 - Implement your code change)
click B "#3-implement-your-code-change"
C(4 - Run avm pre-commit)
click C "#4-run-avm-pre-commit"
C2(5 - Run pr-check and test tiers locally)
click C2 "#5-run-pr-check-and-test-tiers-locally"
D(6 - Raise or Update PR)
click D "#6-raise-or-update-pr"
E("7 - Approve and monitor CI tests [owner]")
click E "#7-approve-and-monitor-ci-tests"
F{Tests passing?}
G(8 - Review and merge PR)
click G "#8-review-and-merge-pr"
H(9 - Cut a release)
click H "#9-cut-a-release"
Z --> A
A --> B
B --> C
C --> C2
C2 --> D
D --> E
E --> F
F -->|no| B
F -->|yes| G
G --> H
1. Fork [optional]
Note
This step is only needed if you do not have write access to the module repository. Module owners and invited collaborators can skip to step 2.
A fork is your own copy of the repository under your GitHub account. It lets you make changes without needing write access to the upstream repo. Once your changes are ready, you raise a pull request from your fork back to the original repository.
Navigate to the module repository in the Azure GitHub organization.
Click the Fork button in the top right.
Select your GitHub account (or organization) as the destination.
Click Create fork.
Clone your fork locally:
git clone https://github.com/<your-username>/terraform-azure-avm-res-<rp>-<modulename>.git
cd terraform-azure-avm-res-<rp>-<modulename>
Keep your fork in sync with the upstream repository before creating a new branch. You can do this from the GitHub UI by clicking Sync fork on your fork’s main page, or locally:
Create a branch from main to work on your changes:
git checkout -b <your-branch-name>
If this is a new module and the repository does not exist yet, module owners should first follow the Repository Creation Process.
Note
If the module repository does not exist yet, check the Terraform Resource Modules index for the module owner’s contact details (PrimaryModuleOwnerGHHandle column).
3. Implement your code change
Before writing code, review the Terraform specifications and composition guidelines to ensure your contribution complies with AVM’s design principles. For a new module, confirm first that every control-plane resource and supported data-plane operation uses AzAPI. Any AzureRM block must satisfy and document the unsupported data-plane exception in TFFR3.
Initialize local metadata for a new module
For a root module, avm init creates and sets up the GitHub repository, including its root metadata.json. Only module owners run it, through the owner-only repository creation process.
For a new direct child under modules/, specify its approved path and inherit ownership from the root:
Use the approved -ModuleType for pattern or utility modules instead. With -ChildModule, the command is local-only. It prompts for missing required metadata in an interactive terminal (or accepts -InputObject for automation), creates the target directory if needed, and writes only metadata.json. It never overwrites an existing metadata file or creates Terraform source files, examples, or tests; add those yourself according to the composition guidelines. See the metadata guide for required fields and child ownership.
Once you’ve made your changes, stage, commit, and push them:
git add -A
git commit -m "feat: description of your change"git push
Lifecycle hooks
Some examples need setup work before Terraform runs — deploying prerequisites, generating a terraform.tfvars, or seeding a random prefix. AVM supports optional hook scripts for this:
Terraform configurations created for examples, end-to-end tests, tests, or fixtures are part of the module repository and MUST follow TFFR3. Use AzAPI for every supporting control-plane resource. AzureRM may be configured or exercised only when the test covers the module’s documented unsupported data-plane operation; it must not be used to make setup more convenient.
Hook
Location
Runs
pre.ps1
examples/<name>/
before Terraform commands for the example during policy checks and e2e tests
post.ps1
examples/<name>/
after the example, including when its pre-hook or Terraform initialization fails
tflint-pre.ps1
examples/<name>/
after terraform init, before TFLint
setup.ps1
tests/<tier>/ or modules/<name>/tests/<tier>/
before terraform init and terraform test for the target
Warning
Hooks must be PowerShell. Avm.Authoring rejects per-example pre.sh, post.sh, and tflint-pre.sh files, plus setup.sh and teardown.sh files under tests/<tier>/, on presence alone. Adding a .ps1 while leaving the corresponding .sh in place still fails before Terraform runs:
The terraform unit test engine runs PowerShell hooks only.
Refactor these shell hooks to '.ps1': tests/unit/setup.sh
Legacy root-level examples/setup.sh and examples/teardown.sh files are different: Avm.Authoring does not execute or reject them, and there is no global PowerShell equivalent. Move required logic into idempotent per-example pre.ps1 and post.ps1 hooks. Coordinate removal of legacy global hooks with the repository’s centrally managed CI workflow migration.
Each hook runs in its own isolated pwsh subprocess, so environment variables it exports do not reach subsequent Terraform commands. An e2e pre.ps1 can pass values by writing KEY=VALUE lines to examples/<name>/.env; the runner reads the file after the hook and passes the values to the example’s Terraform subprocesses. A unit or integration setup.ps1 uses a .env file at its target root: the repository root or modules/<name>/. For these test hooks, the .env file is two directories above setup.ps1, not beside it.
Because hooks are invoked from an isolated process, anchor paths on $PSScriptRoot rather than relying on the current working directory. Note also that PowerShell does not stop on a failed native command the way set -e does in bash — check $LASTEXITCODE after each Terraform call and throw so a failed hook surfaces immediately instead of later as a confusing downstream error.
4. Run avm pre-commit
Before raising a pull request, run pre-commit to update your files:
avm pre-commit
For Terraform modules, this command:
Synchronizes the centrally governed managed files, which can add, update, or remove files.
Applies deterministic fixes for AVM convention rules.
Runs mapotf transformations.
Formats Terraform files.
Regenerates documentation.
The command intentionally updates the working tree. Review every change it makes, then commit and push again:
git add -A
git commit -m "chore: pre-commit fixes"git push
5. Run pr-check and test tiers locally
After committing the pre-commit changes, run the broader pull request checks:
az login
avm pr-check
avm pr-check requires a clean Git working tree and Azure credentials because its Conftest policy checks create Terraform plans for the examples. It checks managed-file, formatting, and transformation drift, then runs TFLint, Conftest policy checks, AVM convention checks, terraform validate, and documentation drift checks. It does not run the Terraform test tiers; those remain separate commands so failures are reported independently.
Unit testing
AVM convention checks require a unit test fixture under tests/unit. Use mocked providers to keep unit tests fast and free of external dependencies:
avm test unit
The command also runs unit test tiers found under direct modules/<name>/ submodules.
Integration testing
Integration tests under tests/integration deploy real resources and require Azure credentials:
az login
avm test integration
The command also runs integration test tiers found under direct modules/<name>/ submodules. A repository without integration tests reports the tier as skipped rather than passed.
Local e2e testing
Run the e2e test tier to deploy, check idempotency, and destroy resources for each example:
az login
avm test e2e
This tier requires real Azure credentials. Azure CLI authentication is sufficient for local development; no environment variables or service principals are needed. To run one example while iterating:
avm test e2e --example <name>
An example containing .e2eignore is excluded locally. Existing required examples cannot be ignored to bypass checks. The required set is examples/defaults/ for every module class and examples/waf-aligned/ for resource modules; examples/waf-aligned/ is optional for pattern and utility modules. The legacy examples/default/ spelling remains migration-compatible, but new modules must use examples/defaults/. Apply failures caused by transient region, SKU capacity, or quota errors are destroyed and retried up to two times by default; use -MaxRetry 0 to disable retries.
Local e2e testing is especially useful for external contributors, since only module owners can approve credentialed CI e2e runs.
6. Raise or Update PR
Tip
Raise your PR early — don’t wait until everything is perfect. An early PR lets you get validation and test feedback sooner. You can continue pushing commits to the same branch; fork contributions require the handoff below for authenticated e2e testing.
Navigate to the upstream repository on GitHub and click New pull request.
Set the base repository to the upstream AVM repo and base branch to main.
Set your head repository and compare branch to your fork and branch.
Click Create pull request.
Navigate to the repository on GitHub and click New pull request.
Set the base branch to main and the compare branch to your branch.
Click Create pull request.
7. Approve and monitor CI tests
Note
Coordinate credentialed CI runs with a module owner. Unit tests do not require Azure credentials, but external contributors should still run avm pr-check and all applicable test tiers locally before this step.
PR validation and applicable unit and integration tests run automatically. Automatic PR e2e tests require a label on a same-repository PR. A centrally managed Azure test subscription is provided for credentialed jobs, so contributors do not configure CI credentials themselves.
Open a PR early and use these checks while iterating. When the contribution is ready for deployment tests, request an e2e label; delaying those tests avoids unnecessary cloud costs and runtime.
What CI runs
The centrally managed workflow keeps validation and test tiers in separate jobs so a failure produces an actionable signal:
PR validation — runs the equivalent of avm pr-check: managed-file and generated-file drift checks, Terraform formatting, mapotf transformations, TFLint, Conftest policy checks, AVM convention checks, terraform validate, and documentation checks.
Unit tests — runs avm test unit.
Integration tests — runs avm test integration when the repository has integration tests.
End-to-end tests — when selected by a label, tests each selected example independently with the equivalent of avm test e2e --example <name>.
An authorized maintainer must apply at least one of these labels to a same-repository PR:
PR: Run Required E2E Tests runs the applicable required examples for the module class. Resource modules require both defaults and waf-aligned; pattern and utility modules require defaults only. The legacy default spelling is accepted only for migration compatibility.
PR: Run All E2E Tests runs the applicable required examples and all optional examples.
Each e2e job deploys the example, checks idempotency with terraform plan, and destroys the resources. Optional examples containing .e2eignore are excluded; existing required examples cannot be ignored to bypass checks. Missing required examples produce a warning, and that warning is distinct from the existing e2e merge gate.
The current workflow executes present default/defaults baseline examples and waf-aligned. Updated class-aware behavior that makes WAF optional for pattern and utility modules depends on the Tools workflow rollout. Until it is available, do not infer that a workflow label or warning proves this policy is already implemented.
Every selected example must pass the single Report check status merge gate. Manual dispatch is a separate operator path; merge queues are not supported.
If tests fail
Go back to step 3 — fix the issue, run avm pre-commit again, and push your changes. Applicable CI tests re-run on the same PR; automatic e2e execution requires a label to remain on it. For a fork, follow the handoff recovery guidance below.
Running e2e for external contributions
Fork PRs cannot access upstream credentials; a label does not grant them access. An authorized FTE must perform this handoff so the same-repository follow-up PR can run authenticated e2e tests and satisfy the merge gate. Immediately before the handoff, the FTE must review the source code, dependencies and workflow changes for security at the exact current PR head. Review the new head again if it changes. Ensure the GitHub CLI (gh) is authenticated as an authorized FTE with access to the upstream repository, then run the shared Avm.Authoring command:
The command cannot verify which commit was reviewed. It captures the current head and stops if it changes during the handoff. It creates a release branch from main, retargets and merges the fork PR into that branch, then opens a follow-up PR from the release branch to main. An authorized maintainer must apply one of the e2e labels to that follow-up PR. Restrict write access to the release branch and review any later changes before E2E testing or merging the follow-up PR. The FTE’s invocation runs the handoff; no separate confirmation prompt is required. Use --whatif to preview without making changes. The command stops rather than bypassing repository protections. The follow-up PR still goes through the repository’s normal review and CI gates.
If the handoff itself fails, inspect the fork PR and release branch before recovering manually; do not blindly rerun it. If E2E tests fail after a successful handoff, the original fork PR has been merged. Open a new fork PR containing the original changes and fixes, review its current head, and perform a new handoff. Inspect the existing follow-up PR and release branch before proceeding.
Running e2e for your own contributions
For your own same-repository PRs, apply the appropriate label and monitor the selected tests and Report check status gate.
8. Review and merge PR
Important
PR approvals are enforced on all AVM Terraform module repositories. A PR cannot be merged until it has been approved by an authorized module owner.
Finding an approver
First port of call — find a friendly module owner. Look up another active Terraform module owner from the azure-verified-modules-module-contributors Entra group and request a review from them directly. This is the fastest path to approval.
If no module owner is available, fall back to the AVM core team:
Assign the @Azure/azure-verified-modules-engineering-owners GitHub team as a reviewer on the PR.
Address any review comments and push updates to your branch.
Request a re-review once changes are made.
The module owner will merge the PR once approved and tests pass.
For a brand new module being published for the first time, get the module reviewed by the AVM Core team by following the AVM Review Process before merging.
Owner responsibilities
Keep the root metadata.json up to date, including every approved owner, through the metadata review process. Complete owner access approval separately.
Watch PR and issue activity for your module and respond in a timely manner as per SNFR11.
This step is performed by the module owner only. Skip it for metadata-only changes: updates to metadata.json must not trigger a module release. See the metadata maintenance process.
After the PR is merged to main, create a release via GitHub Releases:
Go to the Releases tab and click Draft a new release.
Set Target to the main branch.
Type a new tag (e.g. v0.1.0 for first publish, or increment for subsequent releases). Tags MUST include the v prefix.
Use Generate release notes and credit external contributors.
Click Publish release.
First module publish
For a brand new module, contact the AVM core team (e.g. via the AVM - Module Triage project) to request initial publication to the HashiCorp Registry. Subsequent releases are published automatically.
Important
Continue publishing in the v0.x.y range (e.g., v0.1.0, v0.1.1, v0.2.0) until the AVM team notifies you that v1.0.0 is allowed.
Common mistakes to avoid
Search and update TODO comments that come from the template — remove them once addressed.
Do not commit terraform.lock.hcl — it is excluded by .gitignore.
Update _header.md and SUPPORT.md.
Do not commit terraform.tfvars files.
Do not commit .env files created by lifecycle hooks.
Do not add shell (.sh) lifecycle hooks — see Lifecycle hooks.
Terraform Composition
Important
AzAPI is the required Azure provider for new AVM Terraform modules. Every new resource, pattern, or utility module MUST use the Azure/azapi provider for every control-plane resource and supported data-plane operation.
AzureRM is permitted only for a specific unsupported data-plane/non-ARM API operation under the narrow TFFR3 exception. The exception applies only to that operation; supporting control-plane resources in the module, submodules, examples, end-to-end tests, Terraform tests, fixtures, and documentation snippets MUST use AzAPI.
This guide MUST be used in conjunction with the Terraform specifications. All AVM modules MUST meet the applicable requirements in those specifications.
This repo will be created by the Module Owners and the AVM Core team collaboratively, including the configuration of permissions as per SNFR9
Directory and File Structure
Below is the directory and file structure expected for each AVM Terraform repository/module.
tests/ - (for unit tests and integration tests using Terraform test)
unit/ - (.tftest.hcl files for required unit testing with Terraform test)
setup.ps1 - (optional setup hook)
integration/ - (optional .tftest.hcl files for integration testing with Terraform test)
setup.ps1 - (optional setup hook)
modules/ - (for sub-modules only if used; each submodule root MUST be a direct modules/<name>/ child)
examples/ - (all examples must deploy successfully without interactive input and use AzAPI for supporting control-plane resources; AzureRM may appear only when exercising the module’s documented unsupported data-plane exception - these are customer facing and run as end-to-end tests)
<at least one required folder> - (at least one executable defaults example that uses required inputs and module defaults)
pre.ps1 - (optional setup hook)
post.ps1 - (optional cleanup hook)
tflint-pre.ps1 - (optional setup hook for TFLint)
.e2eignore - (optional marker that excludes the example from e2e testing)
<other folders for examples as required> - (each example root MUST be a direct examples/<name>/ child)
/... - (Module files that live in the root of module directory)
_header.md - (required for documentation generation)
_footer.md - (required for documentation generation)
main.tf
locals.tf
variables.tf
outputs.tf
terraform.tf
README.md (autogenerated)
main.resource1.tf (If a larger module you may chose to use dot notation for each resource)
locals.resource1.tf
See Lifecycle hooks for hook execution, environment, and migration guidance.
Nested Terraform module and example roots are prohibited. Avm.Authoring convention validation enforces the one-layer modules/* and examples/* structure; see TFRMNFR1.
Required examples
Every Terraform module class requires a direct examples/defaults/ example. Resource modules also require direct examples/waf-aligned/. For pattern and utility modules, examples/waf-aligned/ is optional.
The exact normative baseline names are examples/defaults/ and examples/waf-aligned/. examples/default/ is a legacy singular spelling retained only for migration compatibility in existing tooling and repositories. New modules must use examples/defaults/.
Both required scenarios must deploy successfully without interactive input and must clean up resources and dependencies. Required examples must not contain .e2eignore. Optional examples may contain it with a documented reason.
Examples must exercise required and applicable conditional module inputs while relying on module defaults for other inputs. Test-harness resources, deployment scope, and telemetry controls such as enable_telemetry and location must be explicit and separate from the module scenario. Terraform submodules have no separate required example trees; parent examples must cover submodule behavior.
WAF folder names do not prove semantic WAF alignment. See SFR2 and SNFR2.
Code Styling
This section points to conventions to be followed when developing a module.
This section is only relevant for contributions to resource modules.
To meet RMFR4 and RMFR5 AVM resource modules must leverage consistent interfaces for all the optional features/extension resources supported by the AVM module primary resource.
Every Terraform AVM module MUST be built with AzAPI, and every resource module MUST implement the following AzAPI patterns. The cross-references point at the normative specs — this section only summarises them so that nothing here is missed during scaffolding.
Use Azure/azapi for every control-plane resource and supported data-plane operation in the module, submodules, examples/e2e tests, Terraform tests, fixtures, and documentation snippets. AzureRM is permitted only for a documented data-plane/non-ARM operation that AzAPI cannot implement.
Expose the parent scope as a single required parent_id string variable. Do not expose resource_group_name or any other scope-specific input. Validate with provider::azapi::parse_resource_id against the expected parent type.
Implement every ARM subresource as a Terraform submodule under a direct modules/<subresource-singular-name>/ child. Parent modules MUST reference submodules, and submodules MUST be independently consumable. Keep submodule primary resources single-instance only (no count / for_each on azapi_resource.this); cardinality belongs at the module call site. Nested module roots are prohibited.
Name the primary azapi_resourcethis. Satellite resources MUST be named after what they represent (e.g. azapi_resource.lock, azapi_resource.role_assignment, azapi_resource.diagnostic_setting, azapi_resource.private_endpoint), not this.
Always set response_export_values on every AzAPI resource (use [] when nothing needs exporting). Include any read-only properties the module’s outputs or downstream resources depend on.
Set replace_triggers_refs only when body paths require replacement. The non-empty static list MUST contain valid, unique JMESPath expressions; omit the argument when no paths are needed. name and location are already triggers, so don’t repeat them.
Source the type argument of every AzAPI resource from a single resource_types object variable instead of hard-coding type strings. Use one optional key per resource, defaulted to the tested API version, and cascade the relevant subset to each submodule.
Expose an ignore_body_changes object variable so consumers can suppress diffs on body paths derived from non-static values. Use one optional list(string) key per resource (same key naming as resource_types), collapse empty lists to null, and cascade the relevant nested slot to each submodule — never the parent’s own paths.
Validate every variable (or nested attribute) that holds an Azure ARM resource ID using can(provider::azapi::parse_resource_id("Microsoft.X/y", value)). Hand-rolled regex / startswith / length checks MUST NOT be used.
Use the standard file layout (terraform.tf, variables.tf, outputs.tf, main.tf, locals.tf). Larger modules MAY split main.tf into main.<topic>.tf files.
The interface schema files under static/includes/interfaces/tf/ are the canonical, copy-pasteable templates for the variables described by these specs. Treat them as authoritative.
Telemetry
To meet the requirements of SFR3 & SFR4, we use the modtm telemetry provider. This lightweight telemetry provider sends telemetry data to Azure Application Insights via a HTTP POST front end service.
The modtm telemetry provider is included in all Terraform modules and enabled by default through main.telemetry.tf, which is generated and maintained by Avm.Authoring. You do not need to change this configuration.
Make sure that the modtm provider is listed under the required_providers section in the module’s terraform.tf file using the following entry. This is also validated by the linter.
The AVM module review is a critical step before an AVM Terraform module gets published to the Terraform Registry and made publicly available for customers, partners and wider community to consume and contribute to. It serves as a quality assurance step to ensure that the AVM Terraform module complies with the Terraform specifications of AVM. The below process outlines the steps that both the module owner and module reviewer need to follow.
Important
A new module is not eligible for review or publication unless it uses AzAPI for every control-plane resource and supported data-plane operation. Reviewers MUST reject any AzureRM block that does not implement and document the narrow unsupported data-plane/non-ARM API exception in TFFR3. Review the root module, submodules, examples/end-to-end tests, Terraform tests, fixtures, and documentation snippets; all supporting control-plane resources must use AzAPI.
The module owner completes the development of the module in their branch or fork.
The module owner submits a pull request (PR) titled AVM-Review-PR and ensures that all checks are passing on that PR as that is a pre-requisite to request a review.
The module owner assigns the @Azure/azure-verified-modules-engineering-owners GitHub team as reviewer on the PR.
The module owner leaves the following comment as it is on the module proposal in the AVM - Module Triage project by searching for their module proposal by name there.
➕ AVM Terraform Module Review Request
I have completed my initial development of the module and I would like to request a review of my module before publishing it to the Terraform Registry. The latest code is in a PR titled [AVM-Review-PR](REPLACE WITH URL TO YOUR PR) on the module repo and all checks on that PR are passing.
The AVM team moves the module proposal from “In Development” to “In Review” in the AVM - Module Triage project.
The AVM team will assign a module reviewer who will open a blank issue on the module titled “AVM-Review” and populate it with the below mark down. This template already marks the specs as compliant which are covered by the checks that run on the PR. There are some specs which don’t need to be checked at the time of publishing the module therefore they are marked as NA.
➕ AVM Terraform Module Review Issue
Dear module owner,
As per the module ownership requirements and responsibilities at the time of [assignment](REPLACE WITH THE LINK TO THE AVM MODULE PROPOSAL), the AVM Team is opening this issue, requesting you to validate your module against the below AVM specifications and confirm its compliance.
Please don’t close this issue and merge your AVM-Review-PR until advised to do so. This review is a prerequisite for publishing your module’s v0.1.0 in the Terraform Registry. The AVM team is happy to assist with any questions you might have.
Requested Actions
Complete the below task list by ticking off the tasks.
Complete the below table by updating the Compliant column with Yes, No or NA as possible values.
Please use the comments columns to provide additional details especially if the Compliant column is updated to No or NA.
Tasks
Address comments on AVM-Review-PR if any
Ensure that all checks on AVM-Review-PR are passing
Confirm every control-plane resource and supported data-plane operation uses AzAPI across the root module, submodules, examples/e2e tests, Terraform tests, fixtures, and documentation snippets. Any AzureRM block must implement and document the narrow TFFR3 unsupported data-plane exception.
Tick this to acknowledge specs with comment “Module Owner to action this spec post-publish as appropriate” in the table below.
Please update the _header.md file as it contains instructions which - once actioned - need to be replaced with Module Name and Description.
The module reviewer can update the Compliance column for specs in line 42 to 47 to NA, in case the module being reviewed isn’t a pattern module.
The module reviewer reviews the code in the PR and leaves comments to request any necessary updates.
The module reviewer assigns the AVM-Review issue to the module owner and links the AVM-Review Issue to the AVM-Review-PR so that once the module reviewer approves the PR and the module owner merges the AVM-Review-PR, the AMV-Review issue is automatically closed. The module reviews responds to the module owner’s comment on the Module Proposal in AVM Repo with the following
➕ AVM Terraform Module Review Initiation Message
Thank you for requesting a review of your module. The AVM module review process has been initiated, please perform the **Requested Actions** on the AVM-Review issue on the module repo.
The module owner updates the check list and the table in the AVM-Review issue and notifies the module reviewer in a comment.
The module reviewer performs the final review and ensures that all checks in the checklist are complete and the specifications table has been updated with no requirements having compliance as ‘No’.
The module reviewer approves the AVM-Review-PR, and leaves the following comment on the AVM-Review issue with the following comment.
➕ AVM Terraform Module Review Completion Message
Thank you for contributing this module and completing the review process per AVM specs. The AVM-Review-PR has been approved and once you merge it that will close this AVM-Review issue. Please create a release with an initial minor version of `v0.1.0` (tags **MUST** include the `v` prefix) and then contact the AVM core team to publish this module to the HashiCorp Terraform Registry via HCP Terraform. Please continue publishing future versions in the v0.x.y minor range (e.g., `v0.1.0`, `v0.1.1`, `v0.2.0`, etc.) until the AVM team notifies you that publishing `v1.0.0` is allowed.
**Requested Action**: Once the AVM core team has published the module, please update your [module proposal](REPLACE WITH THE LINK TO THE MODULE PROPOSAL) with the following comment.
"The initial review of this module is complete, and the module has been published to the registry by the AVM core team. Requesting AVM team to close this module proposal and mark the module available in the module index.
Terraform Registry Link: <REPLACEWITHTHELINKOFTHEMODULEINTERRAFORMREGISTRY>
GitHub Repo Link: <REPLACEWITHTHELINKOFTHEMODULEINGITHUB>"
Once the module owner perform the requested action in the previous step, the module reviewer updates the module proposal by performing the following steps:
Assign label Status: Module Available :green_circle: to the module proposal.
Verify the module’s root metadata.json, including all approved owners. Correct metadata through a pull request to the module repository using the metadata review process.
Confirm publication to the Terraform Registry. The four-hourly catalog sync publishes the module index automatically once the module is published and its metadata is correct. Close the module proposal after the index shows the module as Available, which moves it from “In Review” to “Done” in the AVM - Module Triage project.
Advanced Topics & FAQ
This page covers advanced scenarios and frequently asked questions that go beyond the standard contribution flow.
Offline and air-gapped module mirroring
The offline sync utility mirrors AVM Terraform modules and rewrites registry dependencies as git references for offline or air-gapped environments.
<br
This utility is an example for advanced users familiar with PowerShell, Git, and Terraform module management. It is provided as-is and is not supported for production use.
Using a custom Azure test subscription
CI normally uses a centrally managed identity and test subscription. To deploy examples in your own Azure tenant and subscription, you can configure a test identity and override the identity, tenant, and subscription for end-to-end execution only. These overrides are independent of AVM’s test subscriptions. PR checks, including the Conftest Terraform plan, and integration tests continue to use the central identity and selected test subscription.
Understand the environments first. The managed workflow runs jobs across several GitHub Environments:
Use a user-assigned managed identity in your target tenant with the appropriate Azure permissions on your test subscription and any required management-group scope. Use a dedicated test environment rather than granting production permissions.
Run this PowerShell 7 script to create a flexible federated identity credential for examples-test-execution and set all three repository override variables. It reads the identity’s client and tenant IDs automatically. Variables are recommended because these IDs are non-secret configuration; repository secrets are also supported.
The script uses Azure CLI az rest with the managed identity preview API. It requires GitHub CLI access to manage Actions variables in the module repository, Azure CLI already authenticated to the identity’s tenant, and permission to read the identity and write and read its federated identity credentials. Replace the placeholders and choose a new credential name: PUT replaces a credential with the same name, and existing override variables will be updated. The target test subscription can differ from the subscription containing the identity.
$moduleOwner = '<MODULE_OWNER>'$moduleRepo = '<MODULE_REPOSITORY>'$identitySubscriptionId = '<IDENTITY_SUBSCRIPTION_ID>'$identityResourceGroup = '<IDENTITY_RESOURCE_GROUP>'$identityName = '<USER_ASSIGNED_IDENTITY_NAME>'$testSubscriptionId = '<TARGET_TEST_SUBSCRIPTION_ID>'$credentialName = 'avm-examples-test-execution'$moduleRepository = "$moduleOwner/$moduleRepo"$repository = gh api "repos/$moduleRepository" `
--jq '{id: .id, owner: {id: .owner.id}}' | ConvertFrom-Json
if ($LASTEXITCODE -ne0-or-not $repository.id -or-not $repository.owner.id) {
throw'Could not retrieve the module repository and owner IDs.'}
$managedIdentity = az identity show `
--subscription $identitySubscriptionId `
--resource-group $identityResourceGroup `
--name $identityName `
--output json | ConvertFrom-Json
if ($LASTEXITCODE -ne0-or-not $managedIdentity.clientId -or-not $managedIdentity.tenantId) {
throw'Could not retrieve the managed identity client and tenant IDs.'}
$subjectPattern = "repository_owner_id:$($repository.owner.id):repository_id:$($repository.id):environment:examples-test-execution:*"$workflowPattern = 'Azure/azure-verified-modules-tools/.github/workflows/terraform-module.yml@*'$expression = "claims['sub'] matches '$subjectPattern' and claims['job_workflow_ref'] matches '$workflowPattern' and claims['repository_id'] eq '$($repository.id)' and claims['repository_owner_id'] eq '$($repository.owner.id)'"$body = @{
properties = @{
issuer = 'https://token.actions.githubusercontent.com' audiences = @('api://AzureADTokenExchange')
claimsMatchingExpression = @{ languageVersion = 1; value = $expression }
}
} | ConvertTo-Json -Depth 5$bodyPath = Join-Path (Get-Location).Path 'avm-e2e-federation.json'if (Test-Path -LiteralPath $bodyPath) { throw'Choose a clean working directory; the JSON file already exists.' }
[System.IO.File]::WriteAllText(
$bodyPath,
$body,
[System.Text.UTF8Encoding]::new($false)
)
$rg = [uri]::EscapeDataString($identityResourceGroup)
$identity = [uri]::EscapeDataString($identityName)
$credential = [uri]::EscapeDataString($credentialName)
$uri = "https://management.azure.com/subscriptions/$identitySubscriptionId/resourceGroups/$rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$identity/federatedIdentityCredentials/$($credential)?api-version=2025-01-31-preview"az rest --method put `
--url $uri `
--headers 'Content-Type=application/json' `
--body '@avm-e2e-federation.json'if ($LASTEXITCODE -ne0) { throw'Credential creation failed.' }
az rest --method get `
--url $uri
if ($LASTEXITCODE -ne0) { throw'Credential readback failed.' }
$overrides = [ordered]@{
ARM_CLIENT_ID_OVERRIDE = $managedIdentity.clientId
ARM_TENANT_ID_OVERRIDE = $managedIdentity.tenantId
ARM_SUBSCRIPTION_ID_OVERRIDE = $testSubscriptionId
}
foreach ($override in $overrides.GetEnumerator()) {
gh variable set $override.Key `
--repo $moduleRepository `
--body $override.Value
if ($LASTEXITCODE -ne0) {
throw"Failed to set repository variable '$($override.Key)'." }
}
gh variable list `
--repo $moduleRepository
if ($LASTEXITCODE -ne0) { throw'Could not list repository variables.' }
Verify the returned issuer, audience, language version, and expression before using the identity. The JSON file contains configuration, not credentials; remove it when finished. The body omits subject because it is mutually exclusive with claimsMatchingExpression.
The customized subject uses immutable owner and repository IDs and the exact execution environment. Its trailing wildcard is necessary to keep the subject comparand within Azure’s 128-character limit; the separate job_workflow_ref clause restricts the reusable workflow to the exact Tools repository and path, wildcarding only its ref. Both immutable ID claims are also checked separately. Do not broaden the repository, environment, or workflow path. The calling workflow must still pin the reusable workflow to a full commit SHA; wildcarding the credential’s ref does not relax that requirement. If authentication fails with AADSTS700213, compare the presented claims with this expression.
The script sets these repository Actions variables. You can also manage them under Settings > Secrets and variables > Actions > Variables:
ARM_CLIENT_ID_OVERRIDE - client ID of the managed identity.
ARM_TENANT_ID_OVERRIDE - tenant ID of the target Azure environment.
ARM_SUBSCRIPTION_ID_OVERRIDE - ID of your target test subscription. This can differ from the subscription containing the managed identity.
Set all three values consistently. During end-to-end execution, nonempty overrides map to the corresponding ARM_* variables; the subscription override takes precedence over the centrally selected subscription. PR checks and integration tests do not use these overrides.
Do not change the repository defaults ARM_CLIENT_ID, ARM_TENANT_ID, or TEST_SUBSCRIPTION_IDS; these are managed by repository synchronization. Leave the shared subscription selection configured, because that job still runs before the overrides are applied. There is no TEST_SUBSCRIPTION_IDS_OVERRIDE.
Tip
The workflow merges repository variables first, then repository secrets, so a same-named override secret masks the variable. If your variables do not take effect, check for conflicting repository override secrets.
Custom variables and secrets for end-to-end tests
Example discovery runs in the approval-protected examples-test environment; example execution runs in examples-test-execution. If execution needs additional variables or secrets:
Add them as repository Actions variables or secrets.
Use TF_VAR_ for Terraform input variables. Other non-protected names are also forwarded to execution and example hooks. Secrets take precedence over same-named variables. Avoid protected runner and GitHub environment names.
OPA (Conftest) policy exceptions
Conftest checks the plan for compliance with the Well-Architected Framework using OPA policies.
If you get policy failures that need an exception, create a .rego file in the exceptions sub-directory of the relevant example:
TFLint checks AVM spec compliance using the AVM custom ruleset. See the AVM TFLint rules guide for every enabled AVM rule, its applicability, exact disable block, and override precedence.
To override a rule, create one of the following HCL files in the root of your module:
File
Scope
avm.tflint.override.hcl
Root module
avm.tflint_module.override.hcl
Submodules
avm.tflint_example.override.hcl
Examples
modules/<name>/avm.tflint.override.hcl
One direct submodule
examples/<name>/avm.tflint.override.hcl
One direct example
Example:
# Disable the required resource id output rule — this is a pattern module.
rule"avm_output_resource_id_required" {
enabled =false}
Include a comment explaining why the rule is disabled.
The target-directory override takes precedence over the matching repository-wide scope override and applies only to that direct submodule or example. AVM permits only modules/* and examples/* Terraform roots; nested module or example roots are prohibited and rejected by Avm.Authoring convention validation. Use a target override instead of weakening an all-submodule or all-example override.
Excluding examples from end-to-end testing
Create a file called .e2eignore in the example directory. Its contents should explain why the example is excluded from tests.
Global test setup and teardown
Avm.Authoring has no global setup or teardown hook. It does not execute or reject the legacy files:
examples/setup.sh
examples/teardown.sh
Move required setup and cleanup into idempotent per-example pre.ps1 and post.ps1 hooks. Coordinate removal of legacy global scripts with the repository’s centrally managed CI workflow migration because older workflows can still invoke them.
Per-example pre and post scripts
For example-specific setup/teardown:
examples/<example_name>/pre.ps1 (optional) — runs before Terraform commands for the example.
examples/<example_name>/post.ps1 (optional) — always runs after the example, including after a pre-hook or initialization failure.
Shell equivalents are rejected. Each PowerShell hook runs in an isolated process; see Lifecycle hooks for .env, path, and error-handling guidance.
Repository synchronization PRs
Repository sync regularly compares each module repository with the shared managed files and opens a PR when updates are available. These PRs are normally merged automatically. Module owners will be informed about one-off PRs that require intervention.
Sync uses the default branch’s root metadata.json for the display name and full owner list. Submit changes to those values through the metadata review process.
A synchronization update can include module source and managed configuration. Review any requested intervention accordingly; source changes need normal validation and release handling. A metadata-only change does not require a module release.
Eventual consistency
The Azure Resource Manager API can be eventually consistent. For example, data plane role assignments may not be available immediately after creation.
Use the AzAPI provider’s retry functionality to handle eventual consistency instead of arbitrary time_sleep delays. The AzAPI provider supports configurable retry with retry blocks that can match on specific error codes, providing a more reliable and efficient approach.
Repository Creation Process
Important
This page is for module owners only. If you are an external contributor, skip to the contribution flow.
Important
Every repository created through this process MUST use AzAPI for every control-plane resource and supported data-plane operation. AzureRM is permitted only for a specific unsupported data-plane/non-ARM API operation under the narrow TFFR3 exception. The exception must be documented and applies only to that operation in the root module, submodules, examples, end-to-end tests, Terraform tests, fixtures, and documentation snippets.
Important
If this process is not followed exactly, it may result in your repository and any in-progress code being permanently deleted.
1. Add yourself to the Module Owners Team and Open Source orgs
If you have already completed these steps, skip to step 2.
Open the Open Source Portal and ensure your GitHub account is linked to your Microsoft account.
Open the Open Source Portal and ensure you are a member of the Azure and Microsoft organizations.
Until your access request is approved, you can contribute by using JIT elevation.
2. Gather repository information
Gather the following approved values from the module request issue. avm init writes them to the root metadata.json in the repository’s first commit.
Information
Description
Repository name
terraform-azure-avm-<type>-<name>, built from the approved module name avm-<type>-<name> (e.g. avm-res-network-virtualnetwork becomes terraform-azure-avm-res-network-virtualnetwork). It is also the name of your local folder.
Module type
resource, pattern, or utility, matching res, ptn, or utl in the module name.
Module display name
Approved display name, supplied as moduleDisplayName
Module description
Approved description, supplied as moduleDescription
Canonical type
Approved ARM resource type (e.g. Microsoft.Network/virtualNetworks) or pattern/utility taxonomy, supplied as canonicalType. Do not infer the value from the module name.
Owners
owners, a PowerShell string array of approved bare GitHub usernames or qualified @organization/team-slug entries
Telemetry ID prefix
Optional telemetryIdPrefix. Supply the assigned identifier if the proposal has one. If you omit it, avm init mints one in the fleet format 46d3xtrf.<res|ptn>.<7 lowercase hex characters> for resource and pattern modules. Never hand-pick an identifier yourself. Utility modules do not use telemetry.
Alternative names
Optional alternativeNames, a PowerShell string array
Record every approved owner. An empty owner array is valid for an unowned module, subject to the proposal and ownership processes. Metadata does not grant access. Later ownership changes use the metadata review process.
3. Create the repository
avm init -Ecosystem terraform creates the GitHub repository, its root metadata and its first commit. You still complete the Open Source Portal, JIT and Direct Owner steps on this page.
The latest Avm.Authoring module, installed from MAR as described in the Terraform prerequisites, including one-time registry registration. To update from MAR, repeat the install command with -Reinstall, then start a new PowerShell session.
AVM core team approval to create the repository.
A configured Git commit identity (git config --global user.name and git config --global user.email).
avm init needs the repo, read:org, and workflow scopes, and gh auth login requests the first two by default. If you are already signed in, run gh auth refresh --hostname "github.com" --scopes "workflow" instead. If you set GH_TOKEN, that token needs the same scopes.
Optional: use an AI agent
An AI agent such as GitHub Copilot CLI can guide you through the rest of this page with the avm-tf-module-repository-creation agent skill. The skill collects the approved values from the module request issue, runs avm init, tells you what to enter in the Open Source Portal, checks the result, and finishes with step 5. It asks for your approval before it creates the repository and before it changes anything in the Open Source Portal for you.
Install the skill for your user account with GitHub CLI 2.90.0 or later:
gh skill install Azure/azure-verified-modules-tools .github/skills/avm-tf-module-repository-creation --scope user
Then ask your agent, for example, to “create the Terraform module repository for avm-res-network-virtualnetwork”. The command installs the skill from the latest Avm.Authoring release, so it matches the released avm init. Run gh skill update avm-tf-module-repository-creation to update it later.
Run avm init
Run these commands from the folder that should contain the repository’s local folder. Replace the placeholders with the approved values.
Use -ModuleType pattern or -ModuleType utility for pattern and utility modules. Add telemetryIdPrefix or alternativeNames to $metadata when needed. In an interactive terminal, you can omit -InputObject and enter the values when avm init prompts for them.
-WhatIf validates the values and lists the stages without making GitHub or filesystem changes. Review the output and obtain the required approval, then run the same command without -WhatIf. avm init then:
Writes metadata.json to the folder. Later runs read the values from this file, so you only supply them once.
Creates the public repository in the Azure organization.
Pauses while you complete the Open Source Portal setup below and elevate with JIT.
Grants the azure-verified-modules-module-contributors team push access and the azure-verified-modules-module-readers team triage access.
Publishes the first commit to main: metadata.json, a minimal module scaffold, and the managed files, telemetry, and README added by avm pre-commit. _header.md starts with the module’s display name and description.
Opens a pull request in microsoft/github-operations from your fork, requesting the Azure Verified Modules and Terraform Cloud GitHub App installations, and prints its link.
Clones the repository into the folder.
Reminds you of the two final Open Source Portal steps: tie the repository to the shared AVM JIT rule in step 4, then, last, leave jaredholgate and jatracey as the only Direct Owners in step 5. avm init cannot check these portal settings, so it lists both as manual every time it completes.
If a stage fails, or you stop the command, fix the reported problem and run the same command again on the same machine. Each stage checks what already exists, so avm init continues where it stopped.
Complete Open Source Portal Setup
avm init pauses after creating the repository and prints the Open Source Portal link and these answers.
➕ If you see the Complete Setup link
Click Complete Setup and use the following settings:
Question
Answer
Classify the repository
Production
Assign a Service tree or Opt-out
Azure Verified Modules / AVM
Direct owners
Add yourself, jaredholgate, and jatracey. Add azure-verified-modules-module-owners as fallback security group. You add yourself temporarily so you can finish the setup; step 5 removes you.
Public open source licensed project?
Yes
What type of open source?
Sample code
License
MIT
All code created by your team?
Yes
Telemetry?
Yes, telemetry
Cryptography?
No
Project name
Azure Verified Module (Terraform) for ‘module name’
Project version
1
Project description
Azure Verified Module (Terraform) for ‘module name’. Part of AVM project - https://aka.ms/avm
Business goals
Create IaC module accelerating Azure deployment using Microsoft best practice.
Used in a Microsoft product?
Open source, can be leveraged in Microsoft services.
Security best practice?
Yes, use just-in-time elevation
Maintainer / Write permissions
Leave empty
Repository template / .gitignore
Uncheck both
Click Finish setup + start business review, then View repository, then Elevate your access.
➕ If you do NOT see the Complete Setup link
Go to the Compliance tab and fill out:
Direct owners: Add yourself, jaredholgate, and jatracey. Add azure-verified-modules-module-owners as fallback. You add yourself temporarily so you can finish the setup; step 5 removes you.
Classify the repository: Production
Service tree: Azure Verified Modules / AVM
Go back to Overview and click Elevate your access if available.
Return to the terminal and type yes to continue. If avm init asks you to elevate again later, click Elevate your access on the repository overview, then type yes.
Note
Maintain the module’s details and full owners array through metadata code-owner review. Complete the Open Source Portal, access-package, and JIT requirements separately.
4. Tie the repository to the shared AVM JIT rule
New repositories default to JIT v1. AVM repositories must use JIT v2 and be tied to the shared service-AVM-azure-verified-modules-module-owners rule, so that just-in-time elevation is governed centrally by the AVM team rather than by a repository-specific rule. Proposing the tie also upgrades the repository to JIT v2.
This is a one-off manual action in the Open Source Portal. Do it after avm init has published the first commit, because it changes how you elevate. You need Direct Owner access to the repository, configured in the previous step. If you do not have permission to propose the tie, skip this step and email avm@microsoft.com with the repository name so the AVM core team can complete it.
Open the repository overview on the Open Source Portal: https://repos.opensource.microsoft.com/orgs/Azure/repos/<repository name>.
Click Advanced JIT options, then select Propose a new tie.
Under Propose tying a new rule to this repository, enter the Rule ID service-AVM-azure-verified-modules-module-owners and click Review.
Confirm the details and click Create tie.
The result page shows whether the tie is active or waiting for approval. On a repository still using JIT v1, a tie proposed by a Direct Owner can become active immediately. Once it is active, the repository overview shows JIT version: JIT v2 and the shared rule.
Info
A pending tie must be approved by an owner of the service-AVM-azure-verified-modules-module-owners rule (an AVM core team member). Ask the AVM core team to approve it. Once approved, just-in-time elevation for the repository is governed by the shared AVM rule.
5. Leave only jaredholgate and jatracey as Direct Owners
Important
This is the last step of the setup. Do it once everything else is done: avm init has completed and the JIT tie from step 4 is in place. The app installation request can still be waiting for approval.
When the setup is finished, jaredholgate and jatracey must be the only individual Direct Owners. Remove everyone else, including yourself and whoever created the repository, and keep azure-verified-modules-module-owners as the fallback security group.
Elevate to administrator: on the repository’s Just-in-time Access tab in the Open Source Portal, select Next, enter a justification, and select the elevate button.
On the repository overview, under Direct Owners, select Change owners. The button is only shown while you are elevated.
Remove every individual Direct Owner other than jaredholgate and jatracey. The first two owner slots are required, and Save stays disabled while either is empty. If removing someone empties a required slot, remove jaredholgate or jatracey from a later slot and add them to the empty required slot instead.
Keep the azure-verified-modules-module-owners fallback security group, then select Save.
Reload the overview and check that Individual Direct Owners lists only jaredholgate and jatracey.
If you cannot change the Direct Owners, email avm@microsoft.com with the repository name so the AVM core team can complete this step.
Info
Module owners retain day-to-day access through the azure-verified-modules-module-owners security group and just-in-time elevation, so you do not need to remain a Direct Owner.
What happens next
The GitHub Apps are installed once the app installation pull request is approved. Running avm init again shows whether the request is still pending.
After the app is installed, repository sync applies the shared repository configuration and managed files to complete the setup.
Sync reads the root metadata.json from the module repository’s default branch for the display name and full owner list.
AVM TFLint Rules
This reference covers the custom AVM TFLint ruleset rules. It does not repeat rules provided by the standard Terraform TFLint plugin. AVM rules are enabled by default. An override is an exception to an AVM requirement and should be narrow, temporary where possible, and explained in the override file.
Rule applicability and overrides
Rules run in the scope that contains the applicable Terraform configuration:
All module scopes - the root module, each submodule, and each example independently.
Module scopes - the root module and each submodule independently; examples are excluded.
Root module - the published module root only.
To disable a rule, use the exact HCL shown in the Disable column. The configuration files and precedence rules are documented in TFLint configuration overrides.
Applicable AzAPI resources expose and apply timeouts.
All module scopes
rule "avm_interface_timeouts" { enabled = false }
Per-rule severity
Version 1.0.0 of the AVM plugin supports an optional severity input on every AVM rule block. The exact supported values are error, warning, and notice. When severity is omitted, the rule keeps its default severity.
This setting is specific to rules provided by the AVM plugin and changes the severity emitted by that rule. It is separate from TFLint’s global --minimum-failure-severity option, which sets the failure threshold for the TFLint process rather than configuring an individual rule’s severity.
Breaking change in v1.0.0: rule names
AVM TFLint ruleset v1.0.0, released through ruleset PR #159, renamed all rules to canonical avm_* names without compatibility aliases. Update the label of every affected TFLint rule block in .tflint.hcl and AVM override files:
These renames apply only to TFLint rule identifiers. Terraform input variable names such as ignore_body_changes, resource_types, retry, and timeouts are unchanged.
Rule guidance
avm_azapi_data_response_export_values_required
Applies TFFR4 to AzAPI data sources: declare response_export_values, including [] when no response fields are needed.
avm_azapi_replace_triggers_refs_valid
Applies TFFR5. Omit replace_triggers_refs when no body paths require replacement. When present, it must be a non-empty static list of valid JMESPath expressions that identify body paths requiring replacement. Entries cannot be blank or duplicated, and cannot include name or location, because AzAPI already replaces the resource when either changes. When the body is statically evaluable, the rule verifies that each declared path resolves against it.
Authors remain responsible for identifying the properties that actually require replacement. Current Bicep-generated schemas do not reliably preserve create-only versus updateable mutability, so this rule validates declared paths but cannot prove that the list is semantically complete.
avm_azapi_resource_tags_required
Applies TFFR9: types with writable tags in the embedded AVM-generated capability snapshot must set tags from a consumer-settable expression. A direct tags = var.tags assignment remains valid, and modules can use the typed resource_tags replacement interface documented by the standard tags interface. Types with read-only or unsupported tags must omit the argument. The rule does not require one exact tags expression and skips dynamic or otherwise unevaluable type expressions.
The ruleset embeds its AVM-generated capability snapshot and works standalone. It does not consume, import, or query AzAPI, and does not accept an external snapshot path.
A weekly ruleset workflow compares the embedded snapshot with upstream data and opens a ruleset pull request when that data changes. Updated capability data ships with the next ruleset release. All users receive snapshot updates by upgrading the ruleset release.
avm_azapi_response_export_values_required
Applies TFFR4: every applicable managed AzAPI resource declares response_export_values, including [] when no fields are exported.
The rule permits non-empty defaults inside any resource field’s optional(list(string), [...]) wrapper, including nested resource fields. It still requires the variable’s top-level default = {} and nullable = false. The empty top-level object does not suppress those field defaults; consumers can override each list or supply [] to disable it. See resource-specific defaults and consumer overrides for examples.
Validates the optional resource_tags variable when it is declared. The variable must default to null and permit null values. Its type must use one or both non-empty, optional resources and modules namespaces without inline defaults. Resource labels must be optional map(string) leaves, module labels must be optional objects that recursively use the same shape, and the complete type must contain at least one resource leaf. The separate namespaces identify Terraform resource and module block labels without collisions.
Validates the tags interface. The backward-compatible tags fallback remains a nullable map(string). When a module exposes resource_tags, its deterministic typed resources and modules namespaces provide complete per-resource replacements without merging.
avm_terraform_literal_heredoc_disallowed
Applies TFNFR40: represent JSON or YAML structured values with jsonencode or yamlencode.
avm_terraform_provider_block_disallowed
Applies TFNFR27: a published module contains no provider blocks; aliases are declared only through configuration_aliases and configured by its consumer.
The standard Terraform TFLint plugin validates required_version and provider requirement declarations. TFNFR25 and TFNFR26 explain the complementary AVM file-layout and ordering requirements.
TFLint configuration overrides
Avm.Authoring loads the following repository-root override files:
File
Default scope
avm.tflint.override.hcl
All root-module checks
avm.tflint_module.override.hcl
All submodule checks
avm.tflint_example.override.hcl
All example checks
modules/<name>/avm.tflint.override.hcl
One direct submodule
examples/<name>/avm.tflint.override.hcl
One direct example
Each file contains normal TFLint rule configuration. For example:
Avm.Authoring merges overrides in this order: the immutable AVM base configuration, the matching repository-root all-scope override, then the target-directory override. A submodule or example override is loaded only for its target directory and takes precedence over the matching all-submodule or all-example file. Use it when an exception is specific to one direct child module or example; do not weaken the corresponding repository-wide default.
AVM permits only one directory layer for Terraform submodule and example roots: modules/* and examples/*. Nested Terraform module or example roots are prohibited, so target overrides apply only to those direct scopes. Avm.Authoring convention validation enforces this structure.
Website Contribution Guide
Looking to contribute to the AVM Website, well you have made it to the right place/page. 👍
Follow the below instructions, especially the pre-requisites, to get started contributing to the library.
Context/Background
Before jumping into the pre-requisites and specific section contribution guidance, please familiarize yourself with this context/background on how this library is built to help you contribute going forward.
This site is built using Hugo, a static site generator, that’s source code is stored in the AVM GitHub repo (link in header of this site too) and is hosted on GitHub Pages, via the repo.
The reason for the combination of Hugo & GitHub pages is to allow us to present an easy to navigate and consume library, rather than using a native GitHub repo, which is not easy to consume when there are lots of pages and folders. Also, Hugo generates the site in such a way that it is also friendly for mobile consumers.
But I don’t have any skills in Hugo?
That’s okay and you really don’t need them. Hugo just needs you to be able to author markdown (.md) files and it does the rest when it generates the site 👍
Pre-Requisites
Read and follow the below sections to leave you in a “ready state” to contribute to AVM.
A “ready state” means you have a forked copy of the Azure/Azure-Verified-Modules repo cloned to your local machine and open in VS Code.
Run and Access a Local Copy of AVM Website During Development
When in VS Code you should be able to open a terminal and run the below commands to access a copy of the AVM website from a local web server, provided by Hugo, using the following address http://localhost:1313/Azure-Verified-Modules/:
cd docs
hugo server -D // you can add "--poll 700ms", if file changes are not detected
Software/Applications
To contribute to this website, you will need the following installed:
Tip
You can use winget to install all the pre-requisites easily for you. See the below section
Steps to do before contributing anything (after pre-requisites)
Run the following commands in your terminal of choice from the directory where you fork of the repo is located:
git checkout main
git pull
git fetch -p
git fetch -p upstream
git pull upstream main
git push
Doing this will ensure you have the latest changes from the upstream repo, and you are ready to now create a new branch from main by running the below commands:
git checkout main
git checkout -b <YOUR-DESIRED-BRANCH-NAME-HERE>
Top Tips
Sometimes the local version of the website may show some inconsistencies that don’t reflect the content you have created
If this happens, simply kill the Hugo local web server by pressing CTRL + C and then restart the Hugo web server by running hugo server -D from the docs/ directory.