Terraform and IaC interview questions
100 Cloud & DevOps practice questions. Read what a strong answer covers, then practise it out loud against the clock.
Practise Terraform and IaC questionsBeginner
- Bringing a manually created resource under Terraform
- count vs for_each
- Creating the same infrastructure for dev and prod
- Declarative vs imperative infrastructure as code
- How infrastructure as code helps disaster recovery
- How Terraform handles dependencies between resources
- Idempotency in infrastructure as code
- Local values
- Pinning Terraform and provider versions
- Plan wants to destroy and recreate a resource unexpectedly
- Protecting critical resources from accidental deletion
- Reading a Terraform plan
- Remote state backends and locking
- Renaming a resource in code without destroying it
- Resources vs data sources
- Sensitive values in Terraform
- Setting up Terraform for a new project
- Someone changed a resource in the console
- Tagging resources consistently with IaC
- terraform apply fails halfway
- Terraform code full of hard-coded values
- Terraform compared with other IaC tools
- terraform fmt and terraform validate
- Terraform providers
- Terraform says the state is locked
- Terraform state
- Terraform state file committed to Git
- Terraform workspaces
- The core Terraform workflow
- Two engineers applying changes at the same time
- Variables and outputs
- What infrastructure as code is
- What Terraform is and how it works
- What Terraform modules are
Intermediate
- A module upgrade breaks consumers
- A resource was deleted outside Terraform
- Cloud API throttling errors during apply
- Creating the backend for Terraform state
- Database passwords visible in Terraform state
- Designing good Terraform modules
- Dynamic blocks
- Forcing a single resource to be recreated
- Import blocks and configuration generation
- Managing resources across many cloud accounts
- Manual fix during an incident conflicts with Terraform
- Moving Terraform state from local to a remote backend
- One team's change breaks another team's infrastructure
- OpenTofu and Terraform licensing
- Plan shows the same change every time
- Platforms for running Terraform at scale
- Policy as code for infrastructure
- Provider aliases for multiple regions or accounts
- Provider upgrade causes unexpected changes in plan
- Provisioners and why to avoid them
- Refactoring with moved and removed blocks
- Removing one item from a list recreates many resources
- Reviewing Terraform pull requests effectively
- Sharing values between Terraform configurations
- Splitting a monolithic Terraform configuration
- Splitting Terraform state into smaller units
- Structuring multiple environments: workspaces, directories or Terragrunt
- Terraform expressions and functions
- terraform plan takes 20 minutes
- Terraform reports a dependency cycle
- Testing Terraform code
- The lifecycle meta-argument
- Where configuration management fits alongside Terraform
Experienced
- A Terraform apply deleted a production database
- A testing strategy for infrastructure code
- An apply was interrupted mid-way
- Applying dependent stacks in the right order
- Auditors require every infrastructure change to be approved and traceable
- Bringing hundreds of manually created resources under Terraform
- Controller-based infrastructure: Crossplane vs Terraform
- Deciding whether to migrate from Terraform to OpenTofu
- Designing an infrastructure as code platform for many teams
- Detecting and handling drift across hundreds of stacks
- Drift detection and remediation strategies
- Engineers keep bypassing infrastructure as code
- Ephemeral environments per pull request with Terraform
- General-purpose languages for infrastructure: Pulumi and CDK
- How Terraform builds and walks its dependency graph
- Hundreds of inconsistent Terraform repositories
- Immutable infrastructure and golden images
- Infrastructure as code strategy for multiple clouds
- Integrating secrets managers with infrastructure as code
- Landing zones and account vending with infrastructure as code
- Limiting blast radius in infrastructure as code
- Migrating from CloudFormation to Terraform
- Plan shows thousands of changes after a provider major upgrade
- Preventing expensive infrastructure mistakes
- Restructuring modules across many states without recreating resources
- Rolling out a breaking change to a widely used module
- Rotating credentials managed by infrastructure code without downtime
- Securing who and what can apply infrastructure changes
- Should Terraform manage Kubernetes workloads?
- Terraform state internals and refresh behaviour
- Terraform state was lost or corrupted
- Using infrastructure as code for regional disaster recovery
- When to write a custom Terraform provider