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 an infrastructure that is already provisioned.
Indeed, for new infrastructures, it is sufficient to write the corresponding Terraform configuration and then execute it in order 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, which may already be being faced in production.
As a partial answer to this problem, we have seen in the Importing existing resources recipe from Chapter 4, Using the Terraform CLI, that we can use the terraform import command...