ExamGecko
Home Home / HashiCorp / Terraform Associate 003

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

Question list
Search
Search

While attempting to deploy resources into your cloud provider using Terraform, you begin to see some odd behavior and experience slow responses. In order to troubleshoot you decide to turn on Terraform debugging. Which environment variables must be configured to make Terraform's logging more verbose?

A.
TF_LOG_PAIH
A.
TF_LOG_PAIH
Answers
B.
TF_LOG
B.
TF_LOG
Answers
C.
TF_VAR_log_path
C.
TF_VAR_log_path
Answers
D.
TF_VAR_log_level
D.
TF_VAR_log_level
Answers
Suggested answer: B

Explanation:

To make Terraform's logging more verbose for troubleshooting purposes, you must configure the TF_LOG environment variable. This variable controls the level of logging and can be set to TRACE, DEBUG, INFO, WARN, or ERROR, with TRACE providing the most verbose output. Reference = Detailed debugging instructions and the use of environment variables like TF_LOG for increasing verbosity are part of Terraform's standard debugging practices

terraform validate reports syntax check errors for which of the following?

A.
Code contains tabs for indentation instead of spaces
A.
Code contains tabs for indentation instead of spaces
Answers
B.
There is a missing value for a variable
B.
There is a missing value for a variable
Answers
C.
The state file does not match the current infrastructure
C.
The state file does not match the current infrastructure
Answers
D.
None of the above
D.
None of the above
Answers
Suggested answer: D

Explanation:

The terraform validate command is used to check for syntax errors and internal consistency within Terraform configurations, such as whether all required arguments are specified. It does not check for indentation styles, missing variable values (as variables might not be defined at validation time), or state file consistency with the current infrastructure. Therefore, none of the provided options are correct in the context of what terraform validate reports. Reference = Terraform's official documentation details the purpose and function of the terraform validate command, specifying that it focuses on syntax and consistency checks within Terraform configurations themselves, not on external factors like the state file or infrastructure state. Direct references from the HashiCorp Terraform Associate (003) study materials to this specific detail were not found in the provided files.

When does Terraform create the .terraform.lock.hc1 file?

A.
After your first terraform plan
A.
After your first terraform plan
Answers
B.
After your first terraform apply
B.
After your first terraform apply
Answers
C.
After your first terraform init
C.
After your first terraform init
Answers
D.
When you enable state locking
D.
When you enable state locking
Answers
Suggested answer: C

Explanation:

Terraform creates the .terraform.lock.hcl file after the first terraform init command. This lock file ensures that the dependencies for your project are consistent across different runs by locking the versions of the providers and modules used.

You want to define multiple data disks as nested blocks inside the resource block for a virtual machine. What Terraform feature would help you define the blocks using the values in a variable?

A.
Local values
A.
Local values
Answers
B.
Count arguments
B.
Count arguments
Answers
C.
Collection functions
C.
Collection functions
Answers
D.
Dynamic blocks
D.
Dynamic blocks
Answers
Suggested answer: D

Explanation:

Dynamic blocks in Terraform allow you to define multiple nested blocks within a resource based on the values of a variable. This feature is particularly useful for scenarios where the number of nested blocks is not fixed and can change based on variable input.

Changing the Terraform backend from the default 'local' backend to a different one after performing your first terrafom apply is:

A.
Optional
A.
Optional
Answers
B.
Impossible
B.
Impossible
Answers
C.
Mandatory
C.
Mandatory
Answers
D.
Discouraged
D.
Discouraged
Answers
Suggested answer: D

Explanation:

Changing the Terraform backend after performing the initial terraform apply is technically possible but strongly discouraged. This is because changing backends can lead to complexities in state management, requiring manual intervention such as state migration to ensure consistency. Terraform's documentation and best practices advise planning the backend configuration carefully before applying Terraform configurations to avoid such changes. Reference = This guidance is consistent with Terraform's official documentation, which recommends careful consideration and planning of backend configurations to avoid the need for changes.

Which type of block fetches or computes information for use elsewhere in a Terraform configuration?

A.
data
A.
data
Answers
B.
local
B.
local
Answers
C.
resource
C.
resource
Answers
D.
provider
D.
provider
Answers
Suggested answer: A

Explanation:

In Terraform, a data block is used to fetch or compute information from external sources for use elsewhere in the Terraform configuration. Unlike resource blocks that manage infrastructure, data blocks gather information without directly managing any resources. This can include querying for data from cloud providers, external APIs, or other Terraform states. Reference = This definition and usage of data blocks are covered in Terraform's official documentation, highlighting their role in fetching external information to inform Terraform configurations.

You have a list of numbers that represents the number of free CPU cores on each virtual cluster:

What Terraform function could you use to select the largest number from the list?

A.
top(numcpus)
A.
top(numcpus)
Answers
B.
max(numcpus)
B.
max(numcpus)
Answers
C.
ceil (numcpus)
C.
ceil (numcpus)
Answers
D.
hight[numcpus]
D.
hight[numcpus]
Answers
Suggested answer: B

Explanation:

In Terraform, the max function can be used to select the largest number from a list of numbers. The max function takes multiple arguments and returns the highest one. For the list numcpus = [18, 3, 7, 11, 2], using max(numcpus...) will return 18, which is the largest number in the list.

Terraform documentation on max function: Terraform Functions - max

All modules published on the official Terraform Module Registry have been verified by HasihCorp.

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

Explanation:

Not all modules published on the official Terraform Module Registry have been verified by HashiCorp. While HashiCorp verifies some modules, there are many community-contributed modules that are not verified. Verified modules have a 'Verified' badge indicating that HashiCorp has reviewed them for security and best practices, but the registry also includes unverified modules.

Terraform Module Registry documentation: Terraform Registry

What is the provider for this resource?

A.
Vpc
A.
Vpc
Answers
B.
Test
B.
Test
Answers
C.
Main
C.
Main
Answers
D.
aws
D.
aws
Answers
Suggested answer: D

Explanation:

In the given Terraform configuration snippet:

resource 'aws_vpc' 'main' {

name = 'test'

}

The provider for the resource aws_vpc is aws. The provider is specified by the prefix of the resource type. In this case, aws_vpc indicates that the resource type vpc is provided by the aws provider.

Terraform documentation on providers: Terraform Providers


Which Terraform command checks that your configuration syntax is correct?

A.
terraform validate
A.
terraform validate
Answers
B.
terraform init
B.
terraform init
Answers
C.
terraform show
C.
terraform show
Answers
D.
terraform fmt
D.
terraform fmt
Answers
Suggested answer: A

Explanation:

The terraform validate command is used to check that your Terraform configuration files are syntactically valid and internally consistent. It is a useful command for ensuring your Terraform code is error-free before applying any changes to your infrastructure.

Total 195 questions
Go to page: of 20