How can I safely bring existing AWS infrastructure under Terraform management?

0
1
Asked By MellowCedar47 On

I need to migrate manually created AWS resources into Terraform without disrupting production. The environment includes a VPC with roughly 30 subnets, four EKS clusters, multiple Route 53 records, load balancers, and other related resources. What process or automation would you recommend for importing everything safely and avoiding unexpected changes or resource replacement?

3 Answers

Answered By BrightPanda82 On

Use Terraform import, preferably with import blocks for a migration this large. Since importing dozens of resources manually would be tedious, inventory the resources with the AWS CLI and generate the import blocks or commands with a script. Import by logical component instead of all at once—such as networking, EKS, DNS, and load balancers. Then inspect the imported state and write the matching Terraform configuration. Importing state does not automatically create clean production-ready HCL.

MellowCedar47 -

That makes sense. I’ll look into generating the import blocks instead of handling every resource manually.

Answered By SilverMaple6 On

For a large environment, automation can help with discovery: use the AWS CLI to collect resource IDs and attributes, then generate starter HCL and import commands. Treat the generated code as a draft that needs review. Pay close attention to Route 53 zone IDs and record types, load-balancer listeners and target groups, and AWS defaults that may appear in state but do not need to be explicitly configured. Never apply the first plan blindly against production—review it carefully and make sure no destructive actions are proposed.

Answered By CalmOtter19 On

The safest workflow is: inventory the existing infrastructure, write the Terraform resources or modules, import the resources, inspect them with terraform show or terraform state show, and repeatedly run terraform plan until there are no unexpected changes. Ideally, the first clean plan should show zero resources to add, change, or destroy. Migrate incrementally and validate each component before moving on. Be especially careful with EKS, VPC networking, load balancers, and Route 53 records because small configuration differences can cause replacements or unwanted updates. Test the process in a non-production environment or with a representative subset first, and use separate state boundaries where that makes operational sense.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.