Generating a Terraform configuration for existing Azure infrastructure
When enterprises want to automate their processes and adopt IaC practices (for example, with Terraform), they face the challenge of how to generate code for infrastructure that is already provisioned.
Indeed, for new infrastructure, it is sufficient to write the corresponding Terraform configuration and then execute it to provision it. On the other hand, for resources that are already provisioned, depending on their number and configuration, it can be long and tedious to write all the Terraform configuration and then execute it to also have the corresponding Terraform state file. In addition, this execution of the Terraform configuration can have side effects on these resources.
As a partial answer to this problem, we have seen, in the Importing existing resources recipe from Chapter 5, Managing Terraform State, that we can use the terraform import
command to import the configuration of already provisioned...