Member-only story
Terraform Import Existing Resource with New Import Block
Originally published at https://www.virtualizationhowto.com on July 31, 2023.
Infrastructure as code (IaC) has become a standard for managing complex IT infrastructures. Terraform, a key player in the IaC sphere, is quite familiar to DevOps engineers and developers alike. One of the essential commands within the Terraform toolset is the terraform import command allowing the import of existing resources. There are some challenges with the legacy terraform import command. However, with the release of Terraform 1.5, Hashicorp has introduced new import functionality. Let’s dive into Terraform import existing resources step-by-step and see how this is done in 1.5 and higher.
What is Terraform?
Terraform is a very popular player in Infrastructure as Code (IaC) solutions developed by HashiCorp. It offers a practical way for DevOps teams to define and manage resources across many cloud providers, including but not limited to AWS, Google Cloud, Azure and VMware vSphere.
The core function of Terraform revolves around writing declarative configuration files. These configuration files allow teams to describe their target environment in a human-readable format, thus enabling the automatic creation, modification, and destruction of infrastructure resources. This is accomplished using HashiCorp Configuration Language (HCL), the language used in the provider configuration, allowing for an efficient way to define resources.