terraform Interview Questions:
==============================
1).Terraform Practical Interview Questions (Experienced)
1. Real-time Scenario Questions
👉 Q1:
You have created infrastructure manually in AWS. Now you need to bring it under Terraform. How will you do it?
Expected Answer:
Use terraform import
Write resource block first
Import using:
terraform import aws_instance.myec2 i-1234567890
Run terraform plan to verify
👉 Q2:
You deleted a resource manually in AWS, but Terraform state still has it. What will you do?
Answer:
Run:
terraform refresh
OR
terraform apply
Terraform will recreate the resource
👉 Q3:
How will you handle multiple environments (dev, qa, prod)?
Answer:
Use:
Workspaces
Separate backend configs
.tfvars files
Example:
terraform workspace new dev
terraform workspace select dev
👉 Q4:
How do you manage secrets in Terraform?
Answer:
Use:
AWS Secrets Manager
HashiCorp Vault
Environment variables
Avoid hardcoding in .tf files
👉 Q5:
How do you handle remote state?
Answer:
Use S3 backend + DynamoDB locking
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-lock"
}
2. Debugging & Troubleshooting
👉 Q6:
Terraform apply failed in middle. What happens?
Answer:
State file updates partially
Next apply will continue from failed point
👉 Q7:
How do you resolve state file corruption?
Answer:
Restore from backup
Use remote backend (S3 versioning)
👉 Q8:
How to remove resource from state without deleting it?
terraform state rm aws_instance.myec2
👉 Q9:
Difference between taint and replace?
Answer:
taint: mark resource for recreation
replace: force recreation immediately
3. Code & Architecture Design
👉 Q10:
How do you design reusable Terraform code?
Answer:
Use modules
module "vpc" {
source = "./modules/vpc"
}
👉 Q11:
How do you pass variables?
Answer:
CLI
.tfvars
Environment variables
👉 Q12:
What is count vs for_each?
Answer:
count: index-based
for_each: key-based (preferred for maps)
👉 Q13:
How do you create dependencies?
Answer:
Implicit (reference)
Explicit:
depends_on = [aws_vpc.main]
4. CI/CD & Automation
👉 Q14:
How do you integrate Terraform with CI/CD?
Answer:
Jenkins / GitHub Actions pipeline:
terraform init
terraform validate
terraform plan
Approval
terraform apply
👉 Q15:
How do you prevent accidental deletion?
Answer:
lifecycle {
prevent_destroy = true
}
5. Advanced Questions
👉 Q16:
What is state locking and why needed?
Answer:
Prevents concurrent execution
Done via DynamoDB (AWS)
👉 Q17:
How do you manage large infrastructure?
Answer:
Split into modules
Use multiple state files
Use workspaces
👉 Q18:
How do you upgrade Terraform safely?
Answer:
terraform init -upgrade
Check provider compatibility
👉 Q19:
How do you handle drift?
Answer:
terraform plan
Detect changes outside Terraform
👉 Q20:
How to rollback infrastructure?
Answer:
Use previous state file
Version control (Git)
💡 Pro Tips (Interview Booster)
Always mention:
State management
Modules
Security (secrets)
CI/CD
Give real-time examples (AWS EC2, VPC, S3)
Linux Interview Questions: ==================== 1).Have you done any kind of automations into linux os ? 2).How much rate on yourself into linux os ? 3).How to extend the volume group into linux os ? 4).how to check the logical volume and hoe to check t check volume group into linux os ? 5).u know the booting sequences into linux os ? 6).so what we do into the grub into linux os ? 7).have you used find command into linux os ? 8).differnece between find and grep command into linux os ? 9).have to find the files which is modified by 7 days ago .so how to u are going to end used into find command into linux os ? 10).if you want to find all these logs fils and compressed Ito linux os ? 111)..which you find the how much file size is it ? 12).can u find a file which auger then 100mb? 13)How to list out the open files which is finished into the PID into linux os ? 14).what are all the things I have to done into linux os ? 1======= How to good at database side into linux os ? Have you logg...
Comments
Post a Comment