Terraform Introduction Quiz
Quiz
Terraform State File (terraform.tfstate)
The state file is Terraform’s record of managed infrastructure that:
- Maps configuration to real-world resources
- Tracks metadata and resource dependencies
- Enables Terraform to know what currently exists
- Is critical for determining what changes to make
- Helps Terraform calculate the difference between desired and actual state
Did you get it right?
terraform plan phase, what does Terraform do to detect state drift?terraform _____terraform init command initializes a Terraform working directory by downloading providers, initializing modules, and setting up the backend.terraform init command initializes a Terraform working directory by downloading providers, initializing modules, and setting up the backend.terraform.tfstate by default when using a local backend. Terraform also creates a terraform.tfstate.backup file for the previous state.terraform.tfstate by default when using a local backend. Terraform also creates a terraform.tfstate.backup file for the previous state.Terraform Provider
A provider is a plugin that interfaces with an API (cloud provider, SaaS platform, etc.). Providers:
- Translate Terraform commands to API calls
- Handle authentication with the service
- Manage resource lifecycle (create, read, update, delete)
- Examples: AWS, Azure, GCP, Kubernetes, CloudFlare
Terraform supports 100+ providers, enabling multi-cloud infrastructure management.
Did you get it right?
terraform init and should typically be excluded from version control?.terraform/ directory is created by terraform init and contains the local cache, downloaded provider plugins, and modules. It should be excluded from version control as it can be regenerated. The .terraform.lock.hcl file should be committed to lock provider versions..terraform/ directory is created by terraform init and contains the local cache, downloaded provider plugins, and modules. It should be excluded from version control as it can be regenerated. The .terraform.lock.hcl file should be committed to lock provider versions.terraform apply without a saved plan?terraform apply without a saved plan, Terraform re-runs the plan phase to show you what will change and asks for approval before applying. This ensures you always see what’s about to happen.terraform apply without a saved plan, Terraform re-runs the plan phase to show you what will change and asks for approval before applying. This ensures you always see what’s about to happen.Terraform Module
A module is a reusable unit that groups related resources together. Modules enable:
- Code reusability across projects
- Abstraction of complex configurations
- Standardization of infrastructure patterns
- Better organization and maintainability
Examples: VPC module, ECS cluster module, networking module.
All Terraform configurations are technically modules—even a single .tf file is considered the root module.
Did you get it right?
terraform apply, Terraform acquires a state lock to prevent concurrent modifications.terraform plan but only reconciles it during terraform apply.terraform plan but only reconciles it during terraform apply.Terraform Workspace
A workspace is a named state instance for the same configuration. Workspaces allow you to:
- Manage multiple environments (dev, staging, prod) with the same configuration
- Keep separate state files for each environment
- Switch between environments easily
- Avoid duplicating configuration files
Example: Same codebase can deploy to dev, staging, and prod workspaces with different state files for each.
Did you get it right?
terraform _____terraform plan command shows a preview of changes Terraform will make, displaying what will be added (+), changed (~), or destroyed (-) before you apply them.terraform plan command shows a preview of changes Terraform will make, displaying what will be added (+), changed (~), or destroyed (-) before you apply them.Terraform Backend
A backend is where Terraform stores its state file. Backend types include:
- Local: State stored on local filesystem (default)
- Remote: State stored remotely (S3, Terraform Cloud, Azure Blob, etc.)
Remote backends enable:
- Team collaboration (shared state)
- State locking (prevent concurrent modifications)
- Secure storage of sensitive data
- State versioning and backup
Production environments should always use remote backends.
Did you get it right?
.tf extension (e.g., main.tf, variables.tf, outputs.tf). These files are written in HCL (HashiCorp Configuration Language)..tf extension (e.g., main.tf, variables.tf, outputs.tf). These files are written in HCL (HashiCorp Configuration Language).