Sobes.tech
Senior

How have you worked with Terraform? Have you faced the task of translating existing infrastructure under Terraform management?

sobes.tech AI

Answer from AI

I have worked with Terraform for managing cloud infrastructure (AWS, GCP, Azure). The task of migrating existing infrastructure to Terraform often arises when there is a need to centralize management and automate deployment.

The process usually includes the following steps:

  1. Resource Import — using the terraform import command to add existing resources to Terraform's state so it can start tracking them.
  2. Writing Configurations — describing resources in HCL, trying to match the current infrastructure as closely as possible.
  3. Verification and Testing — running terraform plan to check that Terraform does not intend to make unwanted changes.
  4. Gradual Transition — sometimes I migrate in stages to minimize risks.

Example of importing an AWS EC2 resource:

terraform import aws_instance.my_instance i-1234567890abcdef0

After importing, you need to manually describe the resource in the configuration to match the actual state.