Last Updated on August 13, 2025 by Arnav Sharma
Terraform, in case you aren’t aware of it !!
Terraform is an infrastructure as a code tool that enables you to define your data centre resources using high-level configuration language and provision them across multiple clouds. Terraform supports AWS, Azure, Google Cloud Platform, OpenStack, and more.
With Terraform, you can manage your Infrastructure as Code, meaning you can define your data center resources in version control and deploy them across multiple clouds with just a few clicks. Terraform makes it easy to provision and manage your cloud resources from a single platform.
If you’re looking for a way to simplify your cloud infrastructure management, Terraform is the perfect tool for the job.
Azure Terrafy enables users to quickly and easily import their existing Azure infrastructure into Terraform HCL, where they can then import it into Terraform.
You’ll need to satisfy some requirements before you can start using the tool.
Pre-requisites:
- Install Golang: https://go.dev/
- Install Terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli
- Install Chocolatey: https://chocolatey.org/install#individual
Install aztfy
This should take around a minute or two.
go install github.com/Azure/aztfy@latest

Ref. : https://github.com/Azure/aztfy
Login to Azure using AZ Cli:

Validate that you’re in the correct sub and can see the Resource Groups:

To import :
Type command aztfy rg <your resource group name>

This will be executed as below:

Press W to import:

It takes a while to import resources, but you will have a progress bar to show you the status.
The TF files are imported into the working directory:


And done:


Main.tf contains all the exported code:

I help organisations secure their cloud infrastructure and stay ahead of evolving cyber threats. Microsoft MVP and Certified Trainer, author of Mastering Azure Security, and founder of arnav.au — a platform for practical Cloud, Cybersecurity, DevOps and AI content.
Frequently Asked Questions
aztfy is Azure Terrafy, a tool that enables users to quickly and easily import their existing Azure infrastructure into Terraform HCL (HashiCorp Configuration Language). It allows you to convert your current Azure resources into Terraform configuration files that can be managed and versioned in Terraform.
You need to install four things before using aztfy: Golang, Terraform CLI, Chocolatey, and aztfy itself. After installation, you'll also need to log in to Azure using the AZ CLI and validate that you're in the correct subscription to see your Resource Groups.
You can install aztfy using the Go command: `go install github.com/Azure/aztfy@latest`. This installation should take around a minute or two to complete. You can find more information and the source code at https://github.com/Azure/aztfy.
To import an existing Azure resource group into Terraform, use the command: `aztfy rg `. After running this command, press 'W' to start the import process, and aztfy will display a progress bar while it converts your resources.
The imported Terraform configuration files are placed in your working directory. The main configuration code is exported to a `main.tf` file, which contains all the HCL code representing your Azure resources that can now be managed through Terraform.