Featured image of post 'Terrifying' or Converting Azure Resources into Terraform Code

'Terrifying' or Converting Azure Resources into Terraform Code

Converting Azure resources to Terraform resources. Converting static cloud infrastructure to state manageable configuration files.


Convert existing resources in Azure to Terraform files (Terrafy/aztfy)

  • Microsoft Recently released a sweet tool called aztfy. This enables you to ’terrafy’ existing Azure resources. This effectively allows for total conversions of existing data in Azure to be modified and updated/managed using Terraform. Whether it be for backup reasons, future management of resource changes, or cloud implmentation purposes, this could prove extremely useful.


  • Have Go installed in your dev environment
  • Go to Microsoft’s Azure Aztfy Github Page
    • Pull the repository to your local machine and install the go module they provide for aztfy
      • 1
        git clone https://github.com/Azure/aztfy
        cd "Directory-You-Cloned-To"
        go install 

Using Aztfy

Once you have a resource group in Azure, you can run the following command to pull specific resources from that group

  • aztfy Azure-Resource-Group-Here

From here, you can navigate each individual resource within that group and import them individually from Azure to your local machine. It generates the .tf files, terraform state files, and all necessary JSON components.

  • Example of Aztfy Result: Aztfy

Navigate into directory you cloned aztfy to, and double check the clone worked by attempting a terraform apply and if it says no changes needed, you are solid!

Useful Resources

Terraform Resources

comments powered by Disqus
Enthusiastic guy who enjoys the outdoors, flying drones, homelabbing, and of course, all things tech!
Built with Hugo
Theme Stack designed by Jimmy