ExamGecko
Home Home / HashiCorp / Terraform Associate 003

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

Question list
Search
Search

If a module declares a variable with a default, that variable must also be defined within the module.

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

Explanation:

A module can declare a variable with a default value without requiring the caller to define it. This allows the module to provide a sensible default behavior that can be customized by the caller if needed.Reference= [Module Variables]

A terraform apply can not _________ infrastructure.

A.
change
A.
change
Answers
B.
destroy
B.
destroy
Answers
C.
provision
C.
provision
Answers
D.
import
D.
import
Answers
Suggested answer: D

Explanation:

The terraform import command is used to import existing infrastructure into Terraform's state. This allows Terraform to manage and destroy the imported infrastructure as part of the configuration. The terraform import command does not modify the configuration, so the imported resources must be manually added to the configuration after the import.Reference= [Importing Infrastructure]

How is terraform import run?

A.
As a part of terraform init
A.
As a part of terraform init
Answers
B.
As a part of terraform plan
B.
As a part of terraform plan
Answers
C.
As a part of terraform refresh
C.
As a part of terraform refresh
Answers
D.
By an explicit call
D.
By an explicit call
Answers
E.
All of the above
E.
All of the above
Answers
Suggested answer: D

Explanation:

The terraform import command is not part of any other Terraform workflow. It must be explicitly invoked by the user with the appropriate arguments, such as the resource address and the ID of the existing infrastructure to import.Reference= [Importing Infrastructure]

A provider configuration block is required in every Terraform configuration.

Example:

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

Explanation:

A provider configuration block isnotrequired in every Terraform configuration. A provider configuration block can be omitted if its contents would otherwise be empty. Terraform assumes an empty default configuration for any provider that is not explicitly configured. However, some providers may require some configuration arguments (such as endpoint URLs or cloud regions) before they can be used. A provider's documentation should list which configuration arguments it expects.For providers distributed on the Terraform Registry, versioned documentation is available on each provider's page, via the ''Documentation'' link in the provider's header1.Reference= [Provider Configuration]1

You have multiple team members collaborating on infrastructure as code (IaC) using Terraform, and want to apply formatting standards for readability.

How can you format Terraform HCL (HashiCorp Configuration Language) code according to standard Terraform style convention?

A.
Run the terraform fmt command during the code linting phase of your CI/CD process Most Voted
A.
Run the terraform fmt command during the code linting phase of your CI/CD process Most Voted
Answers
B.
Designate one person in each team to review and format everyone's code
B.
Designate one person in each team to review and format everyone's code
Answers
C.
Manually apply two spaces indentation and align equal sign '=' characters in every Terraform file (*.tf)
C.
Manually apply two spaces indentation and align equal sign '=' characters in every Terraform file (*.tf)
Answers
D.
Write a shell script to transform Terraform files using tools such as AWK, Python, and sed
D.
Write a shell script to transform Terraform files using tools such as AWK, Python, and sed
Answers
Suggested answer: A

Explanation:

The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability. Running this command on your configuration files before committing them to source control can help ensure consistency of style between different Terraform codebases, and can also make diffs easier to read.You can also use the -check and -diff options to check if the files are formatted and display the formatting changes respectively2.Running the terraform fmt command during the code linting phase of your CI/CD process can help automate this process and enforce the formatting standards for your team.Reference= [Command: fmt]2

One remote backend configuration always maps to a single remote workspace.

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

Explanation:

The remote backend can work with either a single remote Terraform Cloud workspace, or with multiple similarly-named remote workspaces (like networking-dev and networking-prod). The workspaces block of the backend configuration determines which mode it uses. To use a single remote Terraform Cloud workspace, set workspaces.name to the remote workspace's full name (like networking-prod). To use multiple remote workspaces, set workspaces.prefix to a prefix used in all of the desired remote workspace names. For example, set prefix = ''networking-'' to use Terraform cloud workspaces with names like networking-dev and networking-prod.This is helpful when mapping multiple Terraform CLI workspaces used in a single Terraform configuration to multiple Terraform Cloud workspaces3. However, one remote backend configuration always maps to a single remote workspace, either by name or by prefix. You cannot use both name and prefix in the same backend configuration, or omit both.Doing so will result in a configuration error3.Reference= [Backend Type: remote]3

Which of the following does terraform apply change after you approve the execution plan? (Choose two.)

A.
Cloud infrastructure Most Voted
A.
Cloud infrastructure Most Voted
Answers
B.
The .terraform directory
B.
The .terraform directory
Answers
C.
The execution plan
C.
The execution plan
Answers
D.
State file
D.
State file
Answers
E.
Terraform code
E.
Terraform code
Answers
Suggested answer: A, D

Explanation:

Theterraform applycommand changes both the cloud infrastructure and the state file after you approve the execution plan. The command creates, updates, or destroys the infrastructure resources to match the configuration. It also updates the state file to reflect the new state of the infrastructure. The.terraformdirectory, the execution plan, and the Terraform code are not changed by theterraform applycommand.Reference=Command: applyandPurpose of Terraform State

You are working on some new application features and you want to spin up a copy of your production deployment to perform some quick tests. In order to avoid having to configure a new state backend, what open source Terraform feature would allow you create multiple states but still be associated with your current code?

A.
Terraform data sources
A.
Terraform data sources
Answers
B.
Terraform local values
B.
Terraform local values
Answers
C.
Terraform modules
C.
Terraform modules
Answers
D.
Terraform workspaces
D.
Terraform workspaces
Answers
E.
None of the above
E.
None of the above
Answers
Suggested answer: D

Explanation:

Terraform workspaces allow you to create multiple states but still be associated with your current code. Workspaces are like ''environments'' (e.g. staging, production) for the same configuration. You can use workspaces to spin up a copy of your production deployment for testing purposes without having to configure a new state backend. Terraform data sources, local values, and modules are not features that allow you to create multiple states.Reference=WorkspacesandHow to Use Terraform Workspaces

Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?

A.
terraform state list 'provider_type.name'
A.
terraform state list 'provider_type.name'
Answers
B.
terraform state show 'provider_type.name'
B.
terraform state show 'provider_type.name'
Answers
C.
terraform get 'provider_type.name'
C.
terraform get 'provider_type.name'
Answers
D.
terraform state list
D.
terraform state list
Answers
Suggested answer: B

Explanation:

Theterraform state showcommand allows you to access all of the attributes and details of a resource managed by Terraform. You can use the resource address (e.g.provider_type.name) as an argument to show the information about a specific resource. Theterraform state listcommand only shows the list of resources in the state, not their attributes. Theterraform getcommand downloads and installs modules needed for the configuration. It does not show any information about resources.Reference= [Command: state show] and [Command: state list]

If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?

A.
Run terraform refresh
A.
Run terraform refresh
Answers
B.
It will happen automatically
B.
It will happen automatically
Answers
C.
Manually update the state fire
C.
Manually update the state fire
Answers
D.
Run terraform import
D.
Run terraform import
Answers
Suggested answer: B

Explanation:

If you manually destroy infrastructure, Terraform will automatically detect the change and update the state file during the next plan or apply. Terraform compares the current state of the infrastructure with the desired state in the configuration and generates a plan to reconcile the differences. If a resource is missing from the infrastructure but still exists in the state file, Terraform will attempt to recreate it. If a resource is present in the infrastructure but not in the state file, Terraform will ignore it unless you use the terraform import command to bring it under Terraform's management.Reference= [Terraform State]

Total 195 questions
Go to page: of 20