ExamGecko
Home Home / HashiCorp / Terraform Associate 003

HashiCorp Terraform Associate 003 Practice Test - Questions Answers, Page 15

Question list
Search
Search

You are writing a child Terraform module that provisions an AWS instance. You want to reference the IP address returned by the child module in the root configuration. You name the instance resource 'main'.

Which of these is the correct way to define the output value?

A)

B)

C)

D)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: D

Which configuration consistency errors does terraform validate report?

A.
Terraform module isn't the latest version
A.
Terraform module isn't the latest version
Answers
B.
Differences between local and remote state
B.
Differences between local and remote state
Answers
C.
Declaring a resource identifier more than once
C.
Declaring a resource identifier more than once
Answers
D.
A mix of spaces and tabs in configuration files
D.
A mix of spaces and tabs in configuration files
Answers
Suggested answer: C

Explanation:

Terraform validate reports configuration consistency errors, such as declaring a resource identifier more than once. This means that the same resource type and name combination is used for multiple resource blocks, which is not allowed in Terraform. For example,resource 'aws_instance' 'example' {...}cannot be used more than once in the same configuration. Terraform validate does not report errors related to module versions, state differences, or formatting issues, as these are not relevant for checking the configuration syntax and structure.Reference= [Validate Configuration], [Resource Syntax]

You have used Terraform lo create an ephemeral development environment in the (loud 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 Terraform will delete.

Which command should you use to show all of the resources that mil be deleted? Choose two correct answers.

A.
Run terraform state rm '
A.
Run terraform state rm '
Answers
B.
Run terraform show :destroy
B.
Run terraform show :destroy
Answers
C.
Run terraform destroy and it will first output all the resource that will be deleted before prompting for approval
C.
Run terraform destroy and it will first output all the resource that will be deleted before prompting for approval
Answers
D.
Run terraform plan .destory
D.
Run terraform plan .destory
Answers
Suggested answer: C, D

Explanation:

To see all the resources that Terraform will delete, you can use either of these two commands:

terraform destroywill 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 -destroywill show the plan of destruction without asking for confirmation. You can use this command to review the changes before runningterraform destroy.Reference= : Destroy Infrastructure : Plan Command: Options

You can configure Terraform to log to a file using the TF_LOG environment variable.

A.
True
A.
True
Answers
B.
False
B.
False
Answers
Suggested answer: A

Explanation:

You can configure Terraform to log to a file using the TF_LOG environment variable. This variable can be set to one of the log levels: TRACE, DEBUG, INFO, WARN or ERROR. You can also use the TF_LOG_PATH environment variable to specify a custom log file location.Reference= : Debugging Terraform

When should you run terraform init?

A.
Every time you run terraform apply
A.
Every time you run terraform apply
Answers
B.
Before you start coding a new Terraform project
B.
Before you start coding a new Terraform project
Answers
C.
After you run terraform plan for the time in a new terraform project and before you run terraform apply
C.
After you run terraform plan for the time in a new terraform project and before you run terraform apply
Answers
D.
After you start coding a new terraform project and before you run terraform plan for the first time.
D.
After you start coding a new terraform project and before you run terraform plan for the first time.
Answers
Suggested answer: D

Explanation:

You should runterraform initafter you start coding a new Terraform project and before you runterraform planfor the first time. This command will initialize the working directory by downloading the required providers and modules, creating the initial state file, and performing other necessary tasks.Reference= : Initialize a Terraform Project

What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?

A.
The ability to share modules publicly with any user of Terraform
A.
The ability to share modules publicly with any user of Terraform
Answers
B.
The ability to restrict modules to members of Terraform Cloud or Enterprise organizations
B.
The ability to restrict modules to members of Terraform Cloud or Enterprise organizations
Answers
C.
The ability to tag modules by version or release
C.
The ability to tag modules by version or release
Answers
D.
The ability to share modules with public Terraform users and members of Terraform Cloud Organizations
D.
The ability to share modules with public Terraform users and members of Terraform Cloud Organizations
Answers
Suggested answer: B

Explanation:

The Terraform Cloud private registry provides the ability to restrict modules to members of Terraform Cloud or Enterprise organizations. This allows you to share modules within your organization without exposing them to the public. The private registry also supports importing modules from your private VCS repositories. The public Terraform Module Registry, on the other hand, publishes modules from public Git repositories and makes them available to any user of Terraform.Reference= :Private Registry - Terraform Cloud:Terraform Registry - Provider Documentation

You're writing a Terraform configuration that needs to read input from a local file called id_rsa.pub . Which built-in Terraform function can you use to import the file's contents as a string?

A.
file('id_rsa.pub')
A.
file('id_rsa.pub')
Answers
B.
templaTefil('id_rsa.pub')
B.
templaTefil('id_rsa.pub')
Answers
C.
filebase64('id_rsa.pub')
C.
filebase64('id_rsa.pub')
Answers
D.
fileset<'id_rsa.pub')
D.
fileset<'id_rsa.pub')
Answers
Suggested answer: A

Explanation:

To import the contents of a local file as a string in Terraform, you can use the built-in file function. By specifying file('id_rsa.pub'), Terraform reads the contents of the id_rsa.pub file and uses it as a string within your Terraform configuration. This function is particularly useful for scenarios where you need to include file data directly into your configuration, such as including an SSH public key for provisioning cloud instances. Reference = This information is a standard part of Terraform's functionality with built-in functions, as outlined in Terraform's official documentation and commonly used in various Terraform configurations.

Which of the following arguments are required when declaring a Terraform output?

A.
value
A.
value
Answers
B.
description
B.
description
Answers
C.
default
C.
default
Answers
D.
sensitive
D.
sensitive
Answers
Suggested answer: A

Explanation:

When declaring a Terraform output, the value argument is required. Outputs are a way to extract information from Terraform-managed infrastructure, and the value argument specifies what data will be outputted. While other arguments like description and sensitive can provide additional context or security around the output, value is the only mandatory argument needed to define an output. Reference = The requirement of the value argument for outputs is specified in Terraform's official documentation, which provides guidelines on defining and using outputs in Terraform configurations.

In a Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.

A.
True
A.
True
Answers
B.
False
B.
False
Answers
Suggested answer: B

Explanation:

In Terraform Cloud, speculative plan runs are not automatically started when changes are merged or committed to the version control repository linked to a workspace. Instead, speculative plans are typically triggered as part of proposed changes in merge requests or pull requests to give an indication of what would happen if the changes were applied, without making any real changes to the infrastructure. Actual plan and apply operations in Terraform Cloud workspaces are usually triggered by specific events or configurations defined within the Terraform Cloud workspace settings. Reference = This behavior is part of how Terraform Cloud integrates with version control systems and is documented in Terraform Cloud's usage guidelines and best practices, especially in the context of VCS-driven workflows.

You can access state stored with the local backend by using terraform_remote_state data source.

A.
True
A.
True
Answers
B.
False
B.
False
Answers
Suggested answer: B

Explanation:

You cannot access state stored with the local backend by using the terraform_remote_state data source. The terraform_remote_state data source is used to retrieve the root module output values from some other Terraform configuration using the latest state snapshot from the remote backend. It requires a backend that supports remote state storage, such as S3, Consul, AzureRM, or GCS. The local backend stores the state file locally on the filesystem, which terraform_remote_state cannot access.

Terraform documentation on terraform_remote_state data source: Terraform Remote State Data Source

Example usage of remote state: Example Usage (remote Backend)

Total 195 questions
Go to page: of 20