Interview › Infrastructure as Code (Terraform, Ansible)
How would you onboard an existing manually-built environment into IaC with confidence?
Infrastructure as Code (Terraform, Ansible) · Advanced level
Answer
To onboard a manually built environment, I inventory resources, identify ownership boundaries, create modules or resource blocks, import in small batches, compare generated configuration with standards, fix drift deliberately, add tests and policy, and only then enable automated applies for production.
Technical explanation
Do not import everything into a single state file; choose lifecycle boundaries first.
Run no-op plans before enabling automated apply to prove code matches reality.
Preserve rollback options and backups during the transition.
Keep source manifests or IaC definitions readable enough that reviewers can understand the final desired state.
Use overlays, modules, or roles for reuse, but keep environment-specific differences explicit and reviewable.
Validate generated output in CI before applying it through kubectl, Argo CD, Terraform, or Ansible.
Hands-on example
1. Onboard an existing resource for: How would you onboard an existing manually-built environment into IaC with confidence?
2. Inventory the existing object, then create a matching resource block and import block:
import {
to = aws_s3_bucket.logs
id = "existing-company-logs"
}
resource "aws_s3_bucket" "logs" {
bucket = "existing-company-logs"
}3. Run terraform plan -generate-config-out=generated.tf in a scratch branch when supported for the resource, then clean up the generated configuration to match module standards.
4. Apply the import, run a normal plan, and reconcile every proposed change as intentional, accidental drift, or provider default noise.
5. Repeat in small batches and do not enable automated production apply until no-op plans are reliable.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Infrastructure as Code (Terraform, Ansible) interview questions
- How do you detect and remediate IaC drift continuously rather than only at apply time?
- What recent IaC practice or tool have you adopted, and what did it improve?
- How do you review and approve infrastructure changes safely as a team?
- How do you keep IaC DRY across many similar microservices?
- What are the trade-offs of templating (Helm) versus patching (Kustomize)?
- How does ArgoCD work with Kustomize overlays for multiple environments?
- When would you choose Kustomize over Helm, and can you use them together?
- How is Kustomize integrated natively into kubectl (kubectl apply -k)?