Skip to main content

TERRAFORM-ASSOCIATE-003 Real Exam Questions

HashiCorp Certified: Terraform Associate (003) (HCTA0-003)

547 questions available · Page 1 of 55

Updated Exam DumpsVerified AnswersPass Guarantee

Get Complete Exam Dumps
Question 1 Single choice

How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?

  1. A

    Only Terraform Cloud organization owners can set workspace variables on VCS connected workspaces

  2. B

    Commit a change to the VCS working directory and branch that the Terraform Cloud workspace is connected to

  3. C

    Only members of a VCS organization can open a pull request against repositories that are connected to Terraform Cloud workspaces

  4. D

    Only Terraform Cloud organization owners can approve plans in VCS connected workspaces

Show answer and explanation

Correct answer: B

Explanation

"In a workspace linked to a VCS repository, runs start automatically when you merge or commit changes to version control.

A workspace is linked to one branch of a VCS repository and ignores changes to other branches. You can specify which files and directories within your repository trigger runs. "
https://www.terraform.io/cloud-docs/run/ui#automatically-starting-runs

Question 2 Single choice

A fellow developer on your team is asking for some help in refactoring their Terraform code. As part of their application's architecture, they are going to tear down an existing deployment managed by Terraform and deploy new. However, there is a server resource named aws_instance.ubuntu[1] they would like to keep to
perform some additional analysis.

What command should be used to tell Terraform to no longer manage the resource?

  1. A

    terraform apply rm aws_instance.ubuntu[1]

  2. B

    terraform state rm aws_instance.ubuntu[1]

  3. C

    terraform plan rm aws_instance.ubuntu[1]

  4. D

    terraform delete aws_instance.ubuntu[1]

Show answer and explanation

Correct answer: B

Explanation

"You can use terraform state rm in the less common situation where you wish to remove a binding to an existing remote object without first destroying it, which will effectively make Terraform "forget" the object while it continues to exist in the remote system."
https://www.terraform.io/cli/commands/state/rm

Question 3 Single choice

Your team lead does not trust the junior terraform engineers who now have access to the git repo . So , he wants you to have some sort of a checking layer , whereby , you can ensure that the juniors will not create any non-compliant resources that might lead to a security audit failure in future.

What can you do to efficiently enforce this?

  1. A

    Create a design /security document (in PDF) and share to the team , and ask them to always follow that document , and never deviate from it.

  2. B

    Since your team is using Hashicorp Terraform Enterprise Edition , enable Sentinel , and write Policy-
    As-Code rules that will check for non-compliant resource provisioning , and prevent/report them.

  3. C

    Use Terraform OSS Sentinel Lite version , which will save cost , since there is no charge for OSS , but it can still check for most non-compliant rules using Policy-As-Code.

  4. D

    Create a git master branch , and implement PR . Every change needs to be reviewed by you , before being merged to the master branch.

Show answer and explanation

Correct answer: B

Explanation

Sentinel is an embedded policy-as-code framework integrated with the HashiCorp Enterprise products. It enables fine-grained, logic-based policy decisions, and can be extended to use information from external sources.
https://www.terraform.io/docs/cloud/sentinel/index.html

Question 4 Single choice

terraform refresh command will not modify infrastructure, but does modify the state file.

  1. A

    True

  2. B

    False

Show answer and explanation

Correct answer: A

Explanation

The terraform refresh command is used to reconcile the state Terraform knows about (via its state file) with the real-world infrastructure. This can be used to detect any drift from the last-known state, and to update the state file. This does not modify infrastructure, but does modify the state file.
https://www.terraform.io/docs/commands/refresh.html

Question 5 Single choice

In the following code snippet, the block type is identified by which string?

  1. A

    "aws_instance"

  2. B

    resource

  3. C

    "db"

  4. D

    instance_type

Show answer and explanation

Correct answer: B

Question 6 Single choice

What is the name assigned by Terraform to reference this resource?

  1. A

    dev

  2. B

    azurerm_resource_group

  3. C

    azurerm

  4. D

    test

Show answer and explanation

Correct answer: A

Question 7 Single choice

Which of the following should you put into the required_providers block?

  1. A

    version >= 3.1

  2. B

    version = ">= 3.1"

  3. C

    version ~> 3.1

Show answer and explanation

Correct answer: B

Explanation

The required_providers block is used to specify the provider versions that the configuration can work with.
The version argument accepts a version constraint string, which must be enclosed in double quotes. The version constraint string can use operators such as >=, ~>, =, etc. to specify the minimum, maximum, or
exact version of the provider. For example, version = ">= 3.1" means that the configuration can work with any provider version that is 3.1 or higher.
References:
[Provider Requirements] and [Version Constraints]

Question 8 Single choice

Select the most accurate statement to describe the Terraform language from the following list.

  1. A

    Terraform is an immutable, declarative, Infrastructure as Code provisioning language based on Hashicorp Configuration Language, or optionally JSON.

  2. B

    Terraform is a mutable, declarative, Infrastructure as Code configuration management language based on Hashicorp Configuration Language, or optionally JSON.

  3. C

    Terraform is an immutable, procedural, Infrastructure as Code configuration management language based on Hashicorp Configuration Language, or optionally JSON.

  4. D

    Terraform is a mutable, procedural, Infrastructure as Code provisioning language based on Hashicorp Configuration Language, or optionally YAML.

Show answer and explanation

Correct answer: A

Explanation

Terraform is not a configuration management tool-
https://www.terraform.io/intro/vs/chefpuppet.html
Terraform is a declarative language-
https://www.terraform.io/docs/configuration/index.html
Terraform supports a syntax that is JSON compatible-
https://www.terraform.io/docs/configuration/syntax-json.html
Terraform is primarily designed on immutable infrastructure principles-
https://www.hashicorp.com/
resources/what-is-mutable-vs-immutable-infrastructure

Question 9 Single choice

Which of the following best describes the default local backend?

  1. A

    The local backend is where Terraform Enterprise stores logs to be processed by an log collector.

  2. B

    The local backend stores state on the local filesystem, locks the state using system APIs, and performs operations locally.

  3. C

    The local backend is the directory where resources deployed by Terraform have direct access to in order to update their current state.

  4. D

    The local backend is how Terraform connects to public cloud services, such as AWS, Azure, or GCP.

Show answer and explanation

Correct answer: B

Explanation

The local backend stores state on the local filesystem, locks that state using system APIs, and performs operations locally.
terraform {
backend "local" { path = "relative/path/to/terraform.tfstate"
}
}
https://www.terraform.io/docs/backends/types/local.html

Question 10 Multiple choice

You have used Terraform to create an ephemeral development environment in the cloud and are now ready to destroy all the infrastructure described by your Terraform configuration. To be safe, you would like to first see all the infrastructure that will be deleted by Terraform.

Which command should you use to show all of the resources that will be deleted? (Choose two.)

  1. A

    Run terraform plan-destroy.

  2. B

    This is not possible. You can only show resources that will be created.

  3. C

    Run terraform state rm *.

  4. D

    Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.

Show answer and explanation

Correct answers: A, D

Explanation

To see all the resources that Terraform will delete, you can use either of these two commands: terraform destroy will show the plan of destruction and ask for your confirmation before proceeding. You can cancel the command if you do not want to destroy the resources. terraform plan -destroy will show the plan of destruction without asking for confirmation. You can use this command to review the changes before running terraform destroy.
References:
Destroy Infrastructure : Plan Command: Reference: (https://www.terraform.io/docs/cli/commands/state/rm.html)