All questions
Showing of 37What is Terraform and how does it differ from other Infrastructure as Code tools?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Terraform is HashiCorp's declarative Infrastructure as Code (IaC) tool. You describe the end state in configuration files, and Terraform works out the steps, where imperative tools make you script each step. Since version 1.6 its license is the Business Source License, which is source-available, not open source.
Compared with other IaC tools, three things stand out:
- It is provider-agnostic. One workflow manages AWS, Azure, Google Cloud and many other services, while CloudFormation is AWS's own tool for AWS resources.
- A state file maps the configuration to the real resources.
terraform planpreviews each change beforeterraform applymakes it.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the basic Terraform workflow.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
You write configuration, initialize the directory with terraform init, then preview and make each change with terraform plan and terraform apply.
- Write configuration in
.tffiles that describe the resources you want. - Initialize the directory with
terraform init, which downloads the providers and modules it needs. - Plan with
terraform plan, which compares the configuration with the current state and previews the changes. - Apply with
terraform apply, which creates, updates or destroys resources to match and records the result in state.
Every later change goes through write, plan and apply again. When an environment is no longer needed, terraform destroy removes everything the configuration manages.
terraform init
terraform plan
terraform apply
terraform destroy # when cleanup is needed
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are Terraform providers and how do you configure them?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Providers are plugins that let Terraform work with cloud platforms, SaaS providers and other APIs. Each one defines the resource types and data sources you can use, such as aws_instance.
You configure a provider in two blocks. required_providers declares its source address and a version constraint, and terraform init downloads a matching release. The provider block sets options such as the region.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-west-2"
}
Here ~> 5.0 accepts any 5.x release but never 6.0, so a major upgrade cannot arrive by surprise.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between a resource and a data source in Terraform?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A resource is an object Terraform creates, updates and destroys, and its block describes the desired state of that object. A data source only reads information about something that already exists, and never changes it.
Terraform records each resource in state and owns its whole lifecycle. A data source fetches attributes of an object managed elsewhere, or of an external system. You reference it with the data. prefix, as in data.aws_vpc.default.id.
# Resource - creates new EC2 instance
resource "aws_instance" "web" {
ami = "ami-12345678"
instance_type = "t2.micro"
}
# Data source - fetches existing VPC info
data "aws_vpc" "default" {
default = true
}
Use a resource for infrastructure this configuration should own. Use a data source when it only needs to look something up, such as the default VPC.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain Terraform variables and their types.
What is the Terraform state file and why is it important?
How do you define outputs in Terraform and why are they useful?
What are the main Terraform configuration files and their purposes?
Explain the terraform init command and when you need to run it.
What is the difference between terraform plan and terraform apply?
What are local values in Terraform, and how do they differ from input variables?
Explain Terraform functions and provide examples.
Explain Terraform modules and their benefits.
What are Terraform workspaces and when should you use them?
Explain remote state backends and their advantages.
What are Terraform data sources, and what are some practical examples?
What are provisioners and when should you avoid them?
Explain dynamic blocks and provide an example.
What are lifecycle rules and when do you use them?
How do you handle sensitive data in Terraform?
Explain count and for_each meta-arguments.
What is drift in Terraform, and how do you detect and fix it?
How does Terraform handle implicit and explicit dependencies between resources?
What does terraform taint do, and what replaced it?
What happens when terraform apply fails halfway, and how do you recover?
How would you organize Terraform state for a large, multi-team infrastructure?
Explain Terraform import and state manipulation commands.
How do you implement infrastructure testing strategies with Terraform?
Explain advanced module patterns and composition strategies.
How do you implement CI/CD pipelines for Terraform?
How do you handle Terraform state conflicts and corruption?
Explain custom provider development and plugin architecture.
How do you implement multi-cloud and hybrid cloud strategies with Terraform?
Explain Terraform performance optimization techniques.
How do you implement disaster recovery and backup strategies for Terraform?
How do you troubleshoot complex Terraform issues?
Explain advanced security practices for Terraform in enterprise environments.
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Terraform cheatsheet
- Core Concepts01
- Terraform Workflow02
- Configuration Basics03
- Variables04
- Outputs05
- Data Sources06
- State Management07
- Modules08
- Provisioners (Use Sparingly!)09
- Functions & Expressions10
- Dependencies11
- Workspaces12
- + 8 more inside
- + 14 more inside
33 of 37 Terraform answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.