HashiCorp Certified: Terraform Associate (004) · Domain 3 · 13% of exam

Core Terraform Workflow

Drill 19 practice questions focused entirely on Core Terraform Workflow for the HashiCorp Terraform Associate exam. Tap an answer for instant feedback and a full explanation — no sign-up, always free.

Verified answer19 questions
Question 1 of 19

A developer runs 'terraform destroy' to tear down a temporary test environment. Later that day, they need the exact same environment back. The configuration files (.tf) and provider lock file are all still present in the working directory, and 'terraform init' has already been run. Which single command will recreate the entire environment as defined in the configuration?

Reviewed for accuracy · Report an issue
Question 2 of 19

A developer has finished editing a Terraform configuration and wants to provision the infrastructure. They have not saved a plan file. Which single command will show the proposed changes and, after interactive approval, create the resources?

Reviewed for accuracy · Report an issue
Question 3 of 19

A new engineer clones your Terraform repository containing several .tf files that reference the AWS provider. They immediately run 'terraform plan' and receive an error stating the provider is not installed and that they must run another command first. Which command must they run before 'terraform plan' will succeed, and why?

Reviewed for accuracy · Report an issue
Question 4 of 19

A junior engineer has finished writing a new Terraform configuration that adds several resources and modifies an existing security group. Before making any changes to the live environment, they want to review exactly what Terraform intends to create, update, or delete so the team can approve the changes during a code review. Which command should they run to produce this preview without altering any real infrastructure?

Reviewed for accuracy · Report an issue
Question 5 of 19

A developer manages three AWS S3 buckets in a single Terraform configuration. To decommission just one bucket, they delete its resource block from the .tf file and run `terraform apply`. The other two buckets must remain untouched. What will Terraform do?

Reviewed for accuracy · Report an issue
Question 6 of 19

A team is collaborating on a Terraform project stored in Git. After one developer runs 'terraform init' locally, a '.terraform.lock.hcl' file is generated. The team lead wants to ensure every team member and the CI pipeline install exactly the same provider versions and verified checksums. What is the recommended practice regarding this file?

Reviewed for accuracy · Report an issue
Question 7 of 19

Your team needs to deploy resources into two different AWS regions (us-east-1 and eu-west-1) from within the same Terraform configuration. You have declared the default AWS provider for us-east-1 and a second provider block with 'alias = "europe"' set to eu-west-1. How do you instruct a specific resource to be created in the eu-west-1 region?

Reviewed for accuracy · Report an issue
Question 8 of 19

Your team wants to allow automatic upgrades to new patch releases of the AWS provider (for bug fixes) but must prevent any minor or major version changes that could introduce breaking behavior. The current version in use is 5.31.0. Which version constraint in the required_providers block satisfies this requirement?

Reviewed for accuracy · Report an issue
Question 9 of 19

A developer spun up a temporary demo environment using Terraform for a week-long product showcase. Now that the event is over, they want to tear down every resource that Terraform provisioned for this configuration to avoid ongoing cloud charges, while keeping the configuration files intact for future reuse. Which command should they run?

Reviewed for accuracy · Report an issue
Question 10 of 19

After running 'terraform init' in a new project directory, a developer inspects the working directory and notices a hidden '.terraform' subdirectory has been created. A teammate asks what should be done with this directory when committing the project to the shared Git repository. What is the correct guidance regarding the '.terraform' directory?

Reviewed for accuracy · Report an issue
Question 11 of 19

A developer has just finished writing a new Terraform configuration and wants to check that the HCL syntax is internally consistent and that all required arguments are present — before running any command that contacts the cloud provider or produces an execution plan. Which command should they run to accomplish this?

Reviewed for accuracy · Report an issue
Question 12 of 19

A developer has just cloned a Terraform repository containing a main.tf that references the AWS and Random providers in its required_providers block. They attempt to run 'terraform plan' immediately but receive an error indicating the required providers are not installed. Which command should they run to download and install the provider plugins into the working directory?

Reviewed for accuracy · Report an issue
Question 13 of 19

Your company runs Terraform in an air-gapped CI environment that has no internet access and cannot reach the public Terraform Registry. The security team has mirrored all required provider plugins into a local directory on the build agents. You need `terraform init` to install providers from that local directory instead of attempting to download them from the registry. Which approach accomplishes this?

Reviewed for accuracy · Report an issue
Question 14 of 19

Your team initially configured Terraform with a local backend. After creating a shared S3 backend block in the configuration, a colleague runs 'terraform init' and is prompted about copying existing state to the new backend. They accidentally decline, and later realize the backend settings in the configuration have changed again. They want to re-run initialization to apply the new backend configuration WITHOUT being prompted to migrate or copy existing state. Which command should they use?

Reviewed for accuracy · Report an issue
Question 15 of 19

A developer clones an existing Terraform project and adds a new resource block for a provider that was not previously used in the configuration. When they run `terraform plan`, Terraform returns an error indicating the provider is not installed and suggests running a command first. Which command must be run to resolve this, and what does it do in this situation?

Reviewed for accuracy · Report an issue
Question 16 of 19

Your team pinned the AWS provider with the constraint "~> 4.20" several months ago, and a .terraform.lock.hcl file currently records version 4.22.0. A newer 4.35.0 release contains a bug fix you need. You update no configuration files but want Terraform to select the latest allowable version within the existing constraint and update the lock file. Which command accomplishes this?

Reviewed for accuracy · Report an issue
Question 17 of 19

Your team runs Terraform in a CI/CD pipeline. Before applying, you want the pipeline to automatically detect whether a plan would make any changes so it can gate the apply step and require manual approval only when changes exist. Which approach correctly leverages the core workflow to accomplish this?

Reviewed for accuracy · Report an issue
Question 18 of 19

A DevOps engineer wants to guarantee that exactly the changes reviewed by a colleague are the ones that get applied to production, with no possibility of the configuration or remote state changing between the review and the deployment. Which sequence of commands best achieves this goal?

Reviewed for accuracy · Report an issue
Question 19 of 19

A developer is writing a new Terraform configuration that manages resources in a private cloud whose provider is published at 'registry.example.com/acme/vcloud'. When they run 'terraform init', Terraform attempts to download the provider from the public HashiCorp registry (registry.terraform.io) and fails. Which addition to the configuration will correctly direct Terraform to the intended provider?

Reviewed for accuracy · Report an issue

More Terraform Associate practice

Keep going with the other HashiCorp Certified: Terraform Associate (004) domains, or take a full timed mock exam.

← Back to Terraform Associate overview