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:
- Resource Import — using the
terraform importcommand to add existing resources to Terraform's state so it can start tracking them. - Writing Configurations — describing resources in HCL, trying to match the current infrastructure as closely as possible.
- Verification and Testing — running
terraform planto check that Terraform does not intend to make unwanted changes. - 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.