You must adopt 200 existing resources and don't want to write all the HCL by hand.
IntermediateScenarioImport Refactoring Drift and Lifecycle
Answer
Situation read → Large brownfield adoption.
What I'd do →
- List the resources by service and tag; script the
importblocks (ID discovery with the AWS CLI). - Run
terraform plan -generate-config-out=generated.tfto draft the HCL. - Clean the generated code: drop computed attributes, replace hardcoded IDs with references, extract variables.
- Iterate until
planshows no changes, then refactor into modules.
Why → Generated config is a starting point and is often noisy; the empty plan is the acceptance test.
Interview tip → Do it in small batches grouped by dependency, not all 200 at once.
More on Import Refactoring Drift and Lifecycle
An S3 bucket was created by hand in the console and now must be managed by Terraform. How do you bring it in?BeginnerHow do you find out that someone changed infrastructure outside Terraform?BeginnerSomeone opened port 22 on a security group in the console. Terraform wants to remove it. What's your process?IntermediateAn Auto Scaling group's desired capacity is changed by autoscaling, and Terraform keeps resetting it.IntermediateHow do you protect a production database from an accidental `terraform destroy`?BeginnerA load balancer's TLS certificate must be rotated with no outage.Intermediate