50 Free Terraform Associate Practice Questions (003)
Preparing for the Terraform Associate certification? These 50 free practice questions cover all five domains of the 003 exam.
Domain 1: Infrastructure as Code Concepts (Questions 1–7)
Question 1
What is the primary difference between declarative and imperative infrastructure management?
a) Declarative defines the desired state; imperative defines the steps to achieve it
b) Imperative defines the desired state; declarative defines the steps
c) Both are the same
d) Declarative is used for networking; imperative for compute
Show Answer
Answer: a) Declarative defines the desired state; imperative defines the steps to achieve it
Explanation: Terraform is declarative — you define the desired state in configuration files, and Terraform determines how to achieve it. Ansible playbooks are also declarative; shell scripts are imperative.
Question 2
What is idempotency in IaC?
a) Running the same configuration produces different results each time
b) Running the same configuration multiple times produces the same result
c) Terraform can only run once
d) Configuration changes are irreversible
Show Answer
Answer: b) Running the same configuration multiple times produces the same result
Explanation: Idempotency means applying the same configuration repeatedly results in the same infrastructure state. This is a key benefit of declarative IaC.
Question 3
What is mutable vs immutable infrastructure?
a) Mutable allows in-place changes; immutable replaces resources
b) Immutable allows in-place changes; mutable replaces resources
c) They are the same
d) Mutable is used in cloud; immutable on-premises
Show Answer
Answer: a) Mutable allows in-place changes; immutable replaces resources
Explanation: Immutable infrastructure replaces entire resources (e.g., recreate a VM with new config) rather than modifying in-place. Terraform supports both but encourages immutable patterns.
Question 4
Which of the following is NOT a benefit of Infrastructure as Code?
a) Consistency across environments
b) Automated provisioning
c) Manual configuration of each server
d) Version-controlled infrastructure
Show Answer
Answer: c) Manual configuration of each server
Explanation: IaC automates and standardizes infrastructure provisioning. Manual configuration is the opposite — it's error-prone and not scalable.
Question 5
What is the difference between configuration management and infrastructure provisioning?
a) Provisioning creates the infrastructure; configuration management configures software on it
b) Configuration management creates infrastructure; provisioning configures software
c) They are the same
d) Provisioning is for servers only
Show Answer
Answer: a) Provisioning creates the infrastructure; configuration management configures software on it
Explanation: Terraform provisions infrastructure (servers, networks, databases). Tools like Ansible, Puppet, or Chef handle configuration management (installing packages, configuring applications).
Question 6
What is the purpose of version-controlling Terraform configurations?
a) Tracking changes, collaboration, and rollback capability
b) Making the code run faster
c) Reducing file size
d) Encrypting the code
Show Answer
Answer: a) Tracking changes, collaboration, and rollback capability
Explanation: Version control (Git) for Terraform configs enables change tracking, team collaboration, code review, and rollback to previous infrastructure states.
Question 7
Which IaC approach does Terraform use?
a) Declarative
b) Imperative
c) Both
d) Neither
Show Answer
Answer: a) Declarative
Explanation: Terraform uses a declarative approach where you describe the desired end state, and Terraform determines the necessary actions to achieve that state.
Domain 2: Understand Terraform's Purpose (Questions 8–15)
Question 8
Which of the following is a key differentiator of Terraform compared to AWS CloudFormation?
a) Terraform is cloud-agnostic
b) Terraform is faster
c) CloudFormation supports more resources
d) CloudFormation uses HCL
Show Answer
Answer: a) Terraform is cloud-agnostic
Explanation: Terraform works with 2000+ providers across AWS, Azure, GCP, Kubernetes, and more. CloudFormation is AWS-only.
Question 9
What is a Terraform provider?
a) A plugin that manages a specific infrastructure platform
b) A module from the registry
c) A configuration file
d) A state backend
Show Answer
Answer: a) A plugin that manages a specific infrastructure platform
Explanation: Providers (e.g., hashicorp/aws, hashicorp/azurerm) are plugins that translate Terraform API calls to provider API calls for resource management.
Question 10
What is the purpose of the required_providers block?
a) Specifying which providers and versions are required for the configuration
b) Installing providers on the local machine
c) Defining provider configurations
d) Creating provider resources
Show Answer
Answer: a) Specifying which providers and versions are required for the configuration
Explanation: required_providers in the terraform block declares provider sources and version constraints, ensuring consistent provider versions across the team.
Question 11
What is the Terraform Registry?
a) A database for storing Terraform state
b) A public repository of Terraform providers and modules
c) A tool for running Terraform in CI/CD
d) A pricing calculator
Show Answer
Answer: b) A public repository of Terraform providers and modules
Explanation: The Terraform Registry (registry.terraform.io) hosts publicly available providers (AWS, Azure, GCP) and modules that can be reused across configurations.
Question 12
What is the difference between Terraform Cloud and Terraform Enterprise?
a) Cloud is SaaS; Enterprise is self-hosted
b) Enterprise is SaaS; Cloud is self-hosted
c) They are the same product
d) Cloud is free; Enterprise is paid
Show Answer
Answer: a) Cloud is SaaS; Enterprise is self-hosted
Explanation: Terraform Cloud is a SaaS service offering remote state, runs, and workspaces. Terraform Enterprise is the self-hosted version for enterprise customers with compliance requirements.
Question 13
Which Terraform feature enables multi-cloud deployments?
a) Providers
b) Modules
c) Workspaces
d) Backends
Show Answer
Answer: a) Providers
Explanation: Terraform can use multiple providers in the same configuration (e.g., AWS + Azure + GCP + Kubernetes), enabling multi-cloud and hybrid cloud deployments.
Question 14
What is the purpose of the terraform login command?
a) Logging into the Terraform Registry to access private modules
b) Creating a user account
c) Authenticating to cloud providers
d) Starting a Terraform session
Show Answer
Answer: a) Logging into the Terraform Registry to access private modules
Explanation: terraform login authenticates to app.terraform.io or Terraform Cloud/Enterprise to access private modules and providers.
Question 15
What does the -chdir flag in Terraform CLI do?
a) Changes the working directory before running the command
b) Creates a new directory
c) Changes the execution directory permanently
d) Directory comparison
Show Answer
Answer: a) Changes the working directory before running the command
Explanation: terraform -chdir=path/to/config runs Terraform commands in the specified directory, useful for running across multiple configurations.
Domain 3: Use the Terraform CLI (Questions 16–24)
Question 16
Which command initializes a Terraform working directory?
a) terraform start
b) terraform init
c) terraform setup
d) terraform begin
Show Answer
Answer: b) terraform init
Explanation: terraform init downloads providers, configures backends, and initializes the working directory. It's the first command to run after writing configuration.
Question 17
Which command formats Terraform configuration files to canonical style?
a) terraform style
b) terraform fmt
c) terraform format
d) terraform lint
Show Answer
Answer: b) terraform fmt
Explanation: terraform fmt rewrites .tf files to a canonical format (indentation, alignment). It uses the -recursive flag to format subdirectories.
Question 18
Which command validates the syntax and internal consistency of Terraform configurations?
a) terraform check
b) terraform validate
c) terraform test
d) terraform lint
Show Answer
Answer: b) terraform validate
Explanation: terraform validate checks for syntax errors, internal references, and required attributes. It doesn't check against actual cloud resources (that's plan).
Question 19
Which command shows the execution plan without applying changes?
a) terraform plan
b) terraform preview
c) terraform simulate
d) terraform check
Show Answer
Answer: a) terraform plan
Explanation: terraform plan creates an execution plan showing what resources will be created, modified, or destroyed. It's safe to run (no changes are made).
Question 20
What does + mean in the terraform plan output?
a) Resource will be destroyed
b) Resource will be created
c) Resource will be modified
d) Resource will be replaced
Show Answer
Answer: b) Resource will be created
Explanation: Plan symbols: + = create, - = destroy, ~ = modify in-place, -/+ = destroy and recreate.
Question 21
Which command destroys all resources defined in the configuration?
a) terraform delete
b) terraform destroy
c) terraform remove
d) terraform clean
Show Answer
Answer: b) terraform destroy
Explanation: terraform destroy terminates all resources defined in the configuration. It asks for confirmation by default (-auto-approve to skip).
Question 22
What is the purpose of terraform state list?
a) Listing resources in the state file
b) Listing resources in the cloud
c) Listing available providers
d) Listing Terraform commands
Show Answer
Answer: a) Listing resources in the state file
Explanation: terraform state list shows all resources tracked in the current state file. Useful for understanding what Terraform is managing.
Question 23
Which command imports existing infrastructure into Terraform state?
a) terraform import
b) terraform state import
c) terraform adopt
d) terraform bring
Show Answer
Answer: a) terraform import
Explanation: terraform import brings existing cloud resources under Terraform management by adding them to state. You must write the configuration first, then import.
Question 24
What is the purpose of terraform output?
a) Displaying output values defined in the configuration
b) Creating output files
c) Printing logs
d) Exporting state to a file
Show Answer
Answer: a) Displaying output values defined in the configuration
Explanation: terraform output shows the values of output blocks defined in the configuration. Outputs are used to share information between modules or display useful information.
Domain 4: Interact with Terraform Modules (Questions 25–31)
Question 25
What is a Terraform module?
a) A collection of Terraform configuration files in a directory
b) A single resource block
c) A provider plugin
d) A state file
Show Answer
Answer: a) A collection of Terraform configuration files in a directory
Explanation: A module is any directory containing .tf files. The root module is the working directory. Child modules are called from the root with the module block.
Question 26
Which module source would you use for a module in the Terraform Registry?
a) source = "terraform-aws-modules/vpc/aws"
b) source = "./modules/vpc"
c) source = "git::https://github.com/org/repo.git"
d) source = "hashicorp/aws"
Show Answer
Answer: a) source = "terraform-aws-modules/vpc/aws"
Explanation: Registry module sources use the format namespace/name/provider. Local modules use ./path. Git modules use git::. Note: hashicorp/aws is a provider, not a module.
Question 27
What is the purpose of the version argument in a module block?
a) Specifying which version of Terraform to use
b) Specifying a version constraint for the module
c) Selecting a provider version
d) Defining the module's output version
Show Answer
Answer: b) Specifying a version constraint for the module
Explanation: version = "~> 3.0" in a module block constrains which module version to use from the registry. Only valid for registry modules.
Question 28
How do you pass data from a child module to the root module?
a) Input variables
b) Output values
c) Local values
d) Data sources
Show Answer
Answer: b) Output values
Explanation: Child modules define output blocks to expose values to the root module. Input variables pass data into modules. Outputs pass data out.
Question 29
What is the standard file structure for a reusable Terraform module?
a) main.tf, variables.tf, outputs.tf
b) main.tf, provider.tf, backend.tf
c) module.tf, config.tf, output.tf
d) terraform.tf, vars.tf, exports.tf
Show Answer
Answer: a) main.tf, variables.tf, outputs.tf
Explanation: The standard module structure includes: main.tf (resources), variables.tf (input parameters), outputs.tf (returned values), and optionally README.md and versions.tf.
Question 30
What is the count meta-argument used for in a module?
a) Counting the number of resources
b) Creating multiple instances of a module from a single module block
c) Limiting the number of provider instances
d) Tracking module versions
Show Answer
Answer: b) Creating multiple instances of a module from a single module block
Explanation: count in a module block creates multiple instances (e.g., count = 3 creates three instances). for_each creates one per item in a map/set.
Question 31
What is the primary benefit of using modules?
a) Reusability, organization, and abstraction
b) Faster execution
c) Reduced state file size
d) Automatic cloud provisioning
Show Answer
Answer: a) Reusability, organization, and abstraction
Explanation: Modules promote code reuse (shareable components), organization (logical grouping), and abstraction (hide complexity behind variables). They follow DRY principles.
Domain 5: Navigate Terraform Core Workflow (Questions 32–50)
Question 32
What is the purpose of terraform apply?
a) Preview changes
b) Execute the changes defined in the plan
c) Remove resources
d) Validate configuration
Show Answer
Answer: b) Execute the changes defined in the plan
Explanation: terraform apply executes the planned changes (creating, modifying, or destroying resources). It can accept a plan file or create a new plan before applying.
Question 33
What is the purpose of terraform.tfvars?
a) Defining provider configurations
b) Setting input variable values
c) Defining output values
d) Configuring the backend
Show Answer
Answer: b) Setting input variable values
Explanation: terraform.tfvars and terraform.tfvars.json files automatically load variable values. Use -var-file flag to specify custom files.
Question 34
What is the variable definition precedence (highest to lowest)?
a) Environment variables → CLI flags → .tfvars files → defaults
b) CLI flags → .tfvars files → Environment variables → defaults
c) .tfvars files → Environment variables → CLI flags → defaults
d) Defaults → Environment variables → CLI flags → .tfvars files
Show Answer
Answer: a) Environment variables → CLI flags → .tfvars files → defaults
Explanation: The precedence order (highest to lowest): TF_VAR_ environment variables, -var and -var-file CLI flags, terraform.tfvars files, and finally default in variable declarations.
Question 35
What is the purpose of a Terraform backend?
a) Storing and managing state remotely
b) Running Terraform commands
c) Installing providers
d) Building modules
Show Answer
Answer: a) Storing and managing state remotely
Explanation: Backends define where state is stored (S3, Terraform Cloud, Azure Storage, GCS). Remote backends enable collaboration, state locking, and secure storage.
Question 36
Why is state locking important?
a) Preventing concurrent modifications to state
b) Encrypting the state file
c) Speeding up Terraform operations
d) Reducing state file size
Show Answer
Answer: a) Preventing concurrent modifications to state
Explanation: State locking prevents two team members from running terraform apply simultaneously, which could corrupt the state file. DynamoDB is commonly used for S3 backend locking.
Question 37
What is the purpose of depends_on?
a) Defining explicit dependencies between resources
b) Creating resource dependencies automatically
c) Ordering resources alphabetically
d) Dependencies between providers
Show Answer
Answer: a) Defining explicit dependencies between resources
Explanation: depends_on creates explicit dependencies when Terraform can't automatically infer them. Usually not needed since implicit references handle most dependencies.
Question 38
What does the for_each meta-argument do?
a) Creates multiple resources based on a map or set of strings
b) Iterates over a list in a single resource
c) Loops through output values
d) Creates resources in a loop
Show Answer
Answer: a) Creates multiple resources based on a map or set of strings
Explanation: for_each creates one resource instance per item in a map or set. Each instance has a unique key. count creates by index number.
Question 39
What is the purpose of a data source in Terraform?
a) Reading and using data from existing infrastructure
b) Creating new infrastructure
c) Storing data in state
d) Importing modules
Show Answer
Answer: a) Reading and using data from existing infrastructure
Explanation: Data sources (data "aws_ami" "ubuntu" {}) query information from existing infrastructure (AMIs, IP ranges, existing resources) without managing them.
Question 40
What is a local value in Terraform?
a) A value stored on the local machine
b) A named expression that can be used multiple times in a module
c) An input variable
d) An output value
Show Answer
Answer: b) A named expression that can be used multiple times in a module
Explanation: Locals (locals { name = "value" }) assign names to expressions for reuse within a module. They simplify configuration and reduce duplication.
Question 41
What is the purpose of the lifecycle meta-argument?
a) Customizing resource lifecycle behavior
b) Defining resource dependencies
c) Creating resource loops
d) Managing provider lifecycle
Show Answer
Answer: a) Customizing resource lifecycle behavior
Explanation: lifecycle customizes resource behavior with create_before_destroy, prevent_destroy, and ignore_changes. It controls how Terraform creates, updates, and destroys resources.
Question 42
Which lifecycle rule prevents accidental deletion of a critical resource?
a) create_before_destroy = true
b) prevent_destroy = true
c) ignore_changes = all
d) replace_triggered_by
Show Answer
Answer: b) prevent_destroy = true
Explanation: prevent_destroy = true causes terraform destroy to fail if the resource is included. It's used for critical resources like databases or production infrastructure.
Question 43
What is a Terraform workspace?
a) A directory for storing configuration files
b) A mechanism for managing multiple state files for the same configuration
c) A cloud-based IDE for Terraform
d) A module repository
Show Answer
Answer: b) A mechanism for managing multiple state files for the same configuration
Explanation: Workspaces allow the same configuration to manage different environments (dev, staging, prod) using separate state files. CLI workspaces are local; Terraform Cloud workspaces are remote.
Question 44
Which expression returns the current workspace name?
a) terraform.workspace
b) var.workspace
c) local.workspace
d) env.workspace
Show Answer
Answer: a) terraform.workspace
Explanation: terraform.workspace is a built-in expression returning the name of the current workspace. It's commonly used for environment-specific configurations.
Question 45
What is a null_resource used for?
a) Creating a resource that doesn't exist
b) Running provisioners or local-exec commands outside a specific resource
c) Creating a module with no resources
d) Destroying all resources
Show Answer
Answer: b) Running provisioners or local-exec commands outside a specific resource
Explanation: null_resource has no configuration but can have provisioners. It's used for triggers or when you need to run a provisioner without an actual resource.
Question 46
What is the purpose of preconditions and postconditions?
a) Validating conditions before or after resource operations
b) Defining resource dependencies
c) Creating pre-configured modules
d) Managing provider versions
Show Answer
Answer: a) Validating conditions before or after resource operations
Explanation: precondition blocks check conditions before creating/updating resources. postcondition blocks validate the result after creation. They prevent error propagation.
Question 47
What is the difference between terraform plan and terraform apply?
a) Plan shows changes; apply executes them
b) Plan executes changes; apply shows them
c) They are the same
d) Plan requires network access; apply doesn't
Show Answer
Answer: a) Plan shows changes; apply executes them
Explanation: plan creates an execution plan (what will happen) without making changes. apply executes the plan and makes the actual infrastructure changes.
Question 48
Which command cleans up cached modules and providers?
a) terraform clean
b) terraform init -reconfigure
c) terraform init -upgrade
d) terraform refresh
Show Answer
Answer: c) terraform init -upgrade
Explanation: terraform init -upgrade updates module and provider versions to the latest allowed by constraints and cleans up unused cached versions.
Question 49
What is the purpose of the sensitive = true argument in output values?
a) Hiding the output value from display
b) Encrypting the output value
c) Marking the value as not shown in CLI output
d) Deleting the output after use
Show Answer
Answer: c) Marking the value as not shown in CLI output
Explanation: sensitive = true prevents the output value from being displayed in terraform output and plan output. It's used for passwords, API keys, and secrets.
Question 50
What is the correct Terraform workflow order?
a) init → plan → apply
b) plan → init → apply
c) apply → init → plan
d) init → apply → plan
Show Answer
Answer: a) init → plan → apply
Explanation: The standard Terraform workflow: 1) init (initialize providers & backends), 2) plan (preview changes), 3) apply (execute changes). Add validate before plan for safety.
How Did You Score?
- 0–25 correct: Review the Terraform Associate Exam Guide.
- 26–40 correct: On track. Practice with hands-on exercises.
- 41–50 correct: Ready for the exam!
Access all Terraform practice questions →
Related Articles
Bereit, dein Wissen zu testen?
Probiere unsere Übungsprüfungen mit Hunderten von realistischen Fragen aus.
Üben starten →