Import Existing Infrastructure to Terraform
Blog post from Stream.Security
Terraform is a robust infrastructure-as-code tool that enables developers to define and manage infrastructure using a declarative language, and it can be used to import and manage existing infrastructure through a series of steps. The process begins with discovering and compiling information about current infrastructure, often using cloud provider tools and APIs, and can be facilitated by services like Lightlytics. Following this, developers generate Terraform JSON configuration files, with tools like Terraformer assisting in automation, to describe the existing resources. After generating these files, users must initialize the Terraform backend and import resources into the Terraform state, allowing further management through Terraform commands. Optionally, JSON configurations can be converted to HashiCorp Configuration Language (HCL) for those who prefer working with it, using tools like json2hcl. The final step involves verifying the Terraform configuration against the existing infrastructure to ensure accuracy, allowing seamless management using Terraform's suite of commands.