Hi, I'm Nicholas đź‘‹
I'm a Senior Platform Engineer

Buy Me A Coffee

Using Azure Verified Modules with Terraform

Date published:

What is AVM and Why Should You Care?

Azure Verified Modules (AVM) is Microsoft’s initiative to provide production-ready, tested, and maintained Terraform and Bicep modules for Azure resources. Think of it as the “official” way to deploy Azure infrastructure with best practices baked right in.

The main goal of AVM lies in its consistency and reliability. Instead of reinventing the wheel every time you need to deploy a resource and test it, you follow Microsoft’s recommendations.

According to Microsoft, the mission of AVM is to:

“Our mission is to deliver a comprehensive Azure Verified Modules library in multiple IaC languages, serving as the trusted Microsoft source of truth.”

Well-Architected Framework - The Azure Verified Modules follow the principles of the Well-Architected Framework, ensuring best practices and reliable infrastructure deployment.

Accelerating Deployment - AVM will empower every person and organization on their IaC journey by accelerating deployment time for Azure resources and architectural patterns.

Supported by Microsoft - This Microsoft-supported initiative aims to be the trusted source for Azure infrastructure as code, driving consistency and reliability.

Key benefits include:

You can check out the official Azure Verified Modules GitHub organization: https://github.com/Azure/Azure-Verified-Modules

Module Types

This diagram illustrates the three module types:

AVM with Bicep vs Terraform

While this blog focuses on Terraform, AVM modules are also available for Bicep. Here’s how they compare:

Terraform AVM modules:

Bicep AVM modules:

Both share the same design principles and naming conventions, making it easy to switch between them based on your team’s preferences.

Getting Started with AVM in Terraform

Let’s jump right into a practical example. Here’s how to structure your Terraform projects when using AVM:

Creating a Virtual Machine with AVM

Here’s a practical example showing how to deploy a Windows virtual machine with proper networking and security:

For the complete example with all configuration options, check out the official documentation: https://registry.terraform.io/modules/Azure/avm-res-compute-virtualmachine/azurerm/latest/examples/windows_minimal

This VM example includes proper networking setup, security group with RDP access, and a Windows Server 2022 virtual machine. The configuration follows Azure best practices with dynamic IP allocation and secure access controls.

You can browse the complete catalog at the AVM Module Index to find modules for your specific needs: https://azure.github.io/Azure-Verified-Modules/

Best Practices

Here are some important lessons when implementing AVM in production:

Version Pinning is Critical Always pin your module versions to avoid unexpected breaking changes. Check the releases page for each module: https://github.com/Azure/terraform-azurerm-avm-res-storage-storageaccount/releases

module “storage_account” { source = “Azure/avm-res-storage-storageaccount/azurerm” version = “= 0.1.2” # Pin to exact version }

Contributing to the AVM Community

The AVM project welcomes contributions! Here’s how you can get involved:

Hands-On Learning with Microsoft Learn Labs

Microsoft provides comprehensive hands-on labs to help you master AVM with Terraform. The AVM Terraform Labs collection offers step-by-step exercises that take you from basic concepts to advanced scenarios.

The labs cover:

You can access these interactive labs here: https://learn.microsoft.com/en-us/samples/azure-samples/avm-terraform-labs/avm-terraform-labs/

Looking Ahead

The AVM ecosystem is rapidly evolving. Microsoft is continuously adding new modules and improving existing ones. Here are some recommendations:

Stay Updated: Follow the AVM GitHub repository for updates: https://github.com/Azure/Azure-Verified-Modules Contribute Back: If you find issues or have improvements, contribute to the community Standardize: Create organization standards around AVM usage for consistency Learn from Examples: Explore the AVM examples repository for real-world scenarios: https://github.com/Azure/terraform-azurerm-avm-examples

Additional Resources

For a deeper dive into AVM concepts and implementation, I recommend watching this comprehensive video from Microsoft:

Conclusion

Azure Verified Modules with Terraform has transformed how to approach Azure infrastructure. The combination of Microsoft’s expertise, community contributions, and Terraform’s flexibility creates a powerful toolchain for modern cloud infrastructure.

If you’re still writing custom Terraform modules for every Azure resource, I recommend giving AVM a try. Start small with a storage account or resource group, and gradually expand your usage as you become more comfortable.

References