HashiCorp Terraform Associate Exam Practice Questions (P. 1)
- Full Access (358 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #1
The terraform.tfstate file always matches your currently built infrastructure.
- ATrue
- BFalseMost Voted
Correct Answer:
B
Reference:
https://www.terraform.io/docs/language/state/index.html
B
Reference:
https://www.terraform.io/docs/language/state/index.html

send
light_mode
delete
Question #2
One remote backend configuration always maps to a single remote workspace.
- ATrue
- BFalseMost Voted
Correct Answer:
A
Reference:
https://www.terraform.io/docs/language/settings/backends/remote.html
A
Reference:
https://www.terraform.io/docs/language/settings/backends/remote.html

send
light_mode
delete
Question #3
How is the Terraform remote backend different than other state backends such as S3, Consul, etc.?
- AIt can execute Terraform runs on dedicated infrastructure on premises or in Terraform CloudMost Voted
- BIt doesn't show the output of a terraform apply locally
- CIt is only available to paying customers
- DAll of the above
Correct Answer:
A
If you and your team are using Terraform to manage meaningful infrastructure, we recommend using the remote backend with Terraform Cloud or Terraform
Enterprise.
Reference:
https://www.terraform.io/docs/language/settings/backends/index.html
A
If you and your team are using Terraform to manage meaningful infrastructure, we recommend using the remote backend with Terraform Cloud or Terraform
Enterprise.
Reference:
https://www.terraform.io/docs/language/settings/backends/index.html
send
light_mode
delete
Question #4
What is the workflow for deploying new infrastructure with Terraform?
- Aterraform plan to import the current infrastructure to the state file, make code changes, and terraform apply to update the infrastructure.
- BWrite a Terraform configuration, run terraform show to view proposed changes, and terraform apply to create new infrastructure.
- Cterraform import to import the current infrastructure to the state file, make code changes, and terraform apply to update the infrastructure.
- DWrite a Terraform configuration, run terraform init, run terraform plan to view planned infrastructure changes, and terraform apply to create new infrastructure.Most Voted
Correct Answer:
D
D

The correct workflow for deploying new infrastructure with Terraform includes writing a configuration file, followed by the initialization of the Terraform working directory using `terraform init`. This step prepares the directory for other commands and loads any necessary plugins. Subsequently, `terraform plan` is used to create an execution plan and shows what actions Terraform will take based on the configuration files. Finally, `terraform apply` is executed to apply the changes required to reach the desired state of the configuration. This sequence ensures a clear, predictable path from code to deployment.
send
light_mode
delete
Question #5
A provider configuration block is required in every Terraform configuration.
Example:

Example:

- ATrue
- BFalseMost Voted
Correct Answer:
A
Reference:
https://github.com/hashicorp/terraform/issues/17928
A
Reference:
https://github.com/hashicorp/terraform/issues/17928
send
light_mode
delete
Question #6
You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script.
Which of the following commands would you use first?
Which of the following commands would you use first?
- Aterraform taint null_resource.run_scriptMost Voted
- Bterraform apply -target=null_resource.run_script
- Cterraform validate null_resource.run_script
- Dterraform plan -target=null_resource.run_script
Correct Answer:
A
A

Using the `terraform taint` command would have previously been the correct method to mark a resource for recreation on the next `terraform apply`. However, it's important to note that the `taint` command is now deprecated and replaced by the `-replace` flag in the `terraform apply` command. Since the question is based on the choices provided and none include the newer `-replace` syntax, the closest correct traditional approach given the scenario and options is indeed selecting `terraform taint`. However, for current practices, using `terraform apply -replace="null_resource.run_script"` would be more appropriate.
send
light_mode
delete
Question #7
Which provisioner invokes a process on the resource created by Terraform?
- Aremote-execMost Voted
- Bnull-exec
- Clocal-exec
- Dfile
Correct Answer:
A
The remote-exec provisioner invokes a script on a remote resource after it is created.
Reference:
https://www.terraform.io/docs/language/resources/provisioners/remote-exec.html
A
The remote-exec provisioner invokes a script on a remote resource after it is created.
Reference:
https://www.terraform.io/docs/language/resources/provisioners/remote-exec.html
send
light_mode
delete
Question #8
Which of the following is not true of Terraform providers?
- AProviders can be written by individuals
- BProviders can be maintained by a community of users
- CSome providers are maintained by HashiCorp
- DMajor cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers
- ENone of the aboveMost Voted
Correct Answer:
D
Reference:
https://jayendrapatil.com/terraform-cheat-sheet/#Terraform_Read_and_write_configuration
D
Reference:
https://jayendrapatil.com/terraform-cheat-sheet/#Terraform_Read_and_write_configuration
send
light_mode
delete
Question #9
What command does Terraform require the first time you run it within a configuration directory?
- Aterraform import
- Bterraform initMost Voted
- Cterraform plan
- Dterraform workspace
Correct Answer:
B
terraform init command is used to initialize a working directory containing Terraform configuration files.
Reference:
https://www.terraform.io/docs/cli/commands/init.html
B
terraform init command is used to initialize a working directory containing Terraform configuration files.
Reference:
https://www.terraform.io/docs/cli/commands/init.html
send
light_mode
delete
Question #10
You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code.
What is the best method to quickly find the IP address of the resource you deployed?
What is the best method to quickly find the IP address of the resource you deployed?
- ARun terraform output ip_address to view the result
- BIn a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file
- CRun terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP addressMost Voted
- DRun terraform destroy then terraform apply and look for the IP address in stdout
Correct Answer:
A
Reference:
https://www.terraform.io/docs/cli/commands/output.html
A
Reference:
https://www.terraform.io/docs/cli/commands/output.html
send
light_mode
delete
All Pages