DevOps Infrastructure as Code 2 — Questions and Answers
Question 1: What is a Terraform 'module'?
- A reusable, self-contained package of Terraform configuration that encapsulates resources (Correct answer)
- A plugin that adds provider support to Terraform
- A remote backend for storing Terraform state
- A policy that restricts what Terraform can create
Correct answer: A reusable, self-contained package of Terraform configuration that encapsulates resources
Terraform modules bundle related resources into reusable, parameterized packages that can be shared across projects and teams.
Question 2: What does 'idempotency' mean in the context of IaC tools like Ansible?
- Running the same operation multiple times produces the same result without unintended side effects (Correct answer)
- Infrastructure is destroyed and recreated on every run
- Changes are applied only once and ignored on subsequent runs
- Each run generates a new unique infrastructure configuration
Correct answer: Running the same operation multiple times produces the same result without unintended side effects
Idempotency means you can run a playbook or Terraform apply multiple times and the end state will always be the same desired state without duplicate or unexpected changes.
Question 3: What is AWS CloudFormation?
- An AWS-native IaC service that provisions resources using JSON or YAML templates (Correct answer)
- A tool for monitoring AWS resource usage and costs
- An AWS service for automating CI/CD pipelines
- A cloud storage service for Terraform state files
Correct answer: An AWS-native IaC service that provisions resources using JSON or YAML templates
AWS CloudFormation allows you to model and provision AWS infrastructure resources using declarative JSON or YAML templates called stacks.
Question 4: What is the difference between mutable and immutable infrastructure?
- Mutable infrastructure is updated in place; immutable infrastructure is replaced entirely for each change (Correct answer)
- Mutable infrastructure uses containers; immutable uses virtual machines
- Mutable infrastructure is managed by IaC; immutable is configured manually
- Mutable infrastructure scales automatically; immutable does not
Correct answer: Mutable infrastructure is updated in place; immutable infrastructure is replaced entirely for each change
Mutable infrastructure is modified after deployment (e.g., patching), while immutable infrastructure is never modified — new images or instances are created and old ones destroyed.
Question 5: What is 'configuration drift' in infrastructure management?
- When the actual state of infrastructure diverges from the declared desired state (Correct answer)
- When IaC templates gradually become outdated as cloud APIs change
- When configuration files conflict across different environments
- When infrastructure costs increase unexpectedly over time
Correct answer: When the actual state of infrastructure diverges from the declared desired state
Configuration drift occurs when manual changes, failed applies, or external modifications cause real infrastructure to diverge from what IaC defines.
Question 6: What is a Terraform 'workspace'?
- An isolated state environment that allows multiple deployments from the same configuration (Correct answer)
- A shared repository for storing Terraform modules
- A GUI for visualizing Terraform infrastructure plans
- A remote execution environment for running Terraform commands
Correct answer: An isolated state environment that allows multiple deployments from the same configuration
Terraform workspaces allow you to maintain separate state files for different environments (dev, staging, prod) using the same configuration codebase.
What is a Terraform 'module'?