Search code examples
azureterraformterraform-provider-azure

Options to extract/export existing azure resources into HCL files


I have a comprehensive, existing and working azure resources that I need to create terraform HCL scripts that deploy them in many another environments.

I like to avoid hand-coding all resources.

Is there any way to automatically (or semi automatically) generate .HCL files based on resources in an Azure resource group?


Solution

  • Unfortunately, there is not a method to automatically generate HCL files based on resources in an Azure resource group. Here is a similar feature request for the Azure template to terraform .tf file converter.

    You need to import existing infrastructure into your Terraform state. If you only need to extract some attributes of existing resources, you can use this Data Source: azurerm_resources to access information about existing resources.