0% found this document useful (0 votes)
469 views11 pages

Terraform Certification Exam - 25 Free Practice Questions

This document provides 25 free practice questions for the Terraform Associate certification exam. It includes multiple choice questions that test knowledge of Terraform concepts like workspaces, variables, providers, and commands. Completing these questions can help familiarize exam takers with the question format and topics covered on the actual exam.

Uploaded by

sabrine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
469 views11 pages

Terraform Certification Exam - 25 Free Practice Questions

This document provides 25 free practice questions for the Terraform Associate certification exam. It includes multiple choice questions that test knowledge of Terraform concepts like workspaces, variables, providers, and commands. Completing these questions can help familiarize exam takers with the question format and topics covered on the actual exam.

Uploaded by

sabrine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now

25 Free Terraform Certification Exam


Questions
By Jeevitha TP

The Terraform Associate certification is for Cloud Engineers. You should have basic terminal skills and an
understanding of on-premises and cloud architecture.

If you are new to the Terraform environment, we recommend you to practice in the demo environment and
also check our Terraform Associate practice exam.

This set of 25 free terraform certification exam questions should give you a solid understanding of how
Terraform associate exam is structured, the question format, and the exam pattern.

HashiCorp Certified Terraform Certification Exam Questions

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 1/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now

Q 1. One of your colleagues is new to Terraform and wants to add a new workspace
named new-hire. What command he should execute from the following?
A. terraform workspace –new –new-hire

B. terraform workspace new new-hire

C. terraform workspace init new-hire

D. terraform workspace new-hire

Option B:

terraform workspace new new-hire is the right syntax to be used whenever you want to create a new
workspace.

Example :

terraform workspace new new-hire

Created and switched to workspace “new-hire “!

Q 2. John is a newbie to Terraform and wants to enable detailed logging to find all
the details

Which environment variable does he need to set?


A. TF_help

B. TF_LOG

C. TF_Debug

D. TF_var_log

Option: B is correct

By default, Terraform does not provide detailed logging. To enable detailed logging, we have to set the
environment variable TF_LOG.

By enabling TF_LOG, you can set to TRACE, INFO, WARN or ERROR, DEBUG Levels.

Q 3. Which option will you use to run provisioners that are not associated with any
resources?

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 2/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

A. Local-exec

Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now
B. Null_resource

C. Salt-masterless

D. Remote-exec

Option B is correct

If you need to run provisioners that aren’t directly associated with a specific resource, you can associate
them with a null_resource.

Refer the link below for Explanation:

Q 4. Which language does terraform support from the below list?


A. XML

B. Javascript

C. Hashicorp Language & JSON

D. Plaintext

Option C is correct

Terraform supports Hashicorp Language & JSON, files ending in .tf and tf.json format.

Q 5. What is the provider version of Google Cloud being used in Terraform?

Google = “~> 1.9.0”


A. 1.9.1

B. 1.0.0

C. 1.8.0

D. 1.9.2

Options A and D are correct

According to the Terraform doc, the operator ~>(Pessimistic Constraint Operator) means only the minor
(rightmost version increase) updates are accepted. Therefore, ~> 1.9.0 means the related module/provider
requirement accepts 1.9.1 to 1.9.x, but not 1.10.0, and absolutely not 1.0.0 or 1.8.0.

Source: expression/version constraints in the Terraform docs.

In reference to this question, terraform is looking for any update above 1.9.0, which can be either 1.9.1 or
1.9.2. Hence, both answers are correct.

Q 6. On executing terraform plan, terraform scans the code and appends any missing
argument before terraform apply.
A. True

B. False

Option: False

On executing terraform plan, terraform scans the code and checks for syntactical errors, missing arguments.
https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 3/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

Users need to fix these warnings before executing the code successfully.
Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now

Q 7. Do terraform workspaces help in adding/allowing multiple state files for a single


configuration?
A. True

B. False

Option: True

Terraform workspaces allow configuring multiple state files and associating with a single configuration file

Q 8. Does terraform standard backend type support remote management system?


A. True

B. False

Option: False

The docs outline two types of backends: enhanced and standard. Enhanced backends are local, which is the
default, and remote, which generally refers to Terraform Cloud. The one major feature of an enhanced
backend is the support for remote operations

Q 9. Does terraform refresh command updates the state files?


A. True

B. False

Option: True

Yes, terraform refresh updates the state files to the latest unless there are any manual changes.

Q 10. Which command is used to launch terraform console?


A. terraform apply -config

B. terraform console

C. terrafrom plan

D. terrafrom consul

Answer : B

terraform console [options] [dir]

This command helps with an interactive command-line console for evaluating and experimenting with
expressions

Q 11. Which of the following below helps users to deploy policy as a code?

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 4/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

A. Resources

Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now
B. Functions

C. Sentinel

D. Workspaces

Answer: C

Policy as code is the idea of writing code in a high-level language to manage and automate policies. By
representing policies as code in text files, proven software development best practices can be adopted such
as version control, automated testing, and automated deployment.

Sentinel is built around the idea and provides all the benefits of policy as code.

Q 12. You have been asked to stop using static values and make code more dynamic.
How can you achieve it? Select the correct option from below.
A. Local values

B. Input variables

C. Depends_on

D. Functions

Answer: B

If we compare terraform with any conventional programming language, then,

Input Variables: Input variables are equivalent to function arguments.(Correct Answer)

Local Values: Local value are like function’s temporary local variables.

Terraform Functions: The Terraform language includes a number of built-in functions that you can call from
within expressions to transform and combine values. The Terraform language does not support user-defined
functions, and so only the functions built in to the language are available for use.

Depends_On: It is a meta argument to signify explicit dependencies in terraform resource creation.

Q 13. Which of the following flags can be used with terraform apply command?
A. Auto-approve

B. Init

C. Get

D. Console

Answer – A

The behavior of terraform apply differs significantly depending on whether you pass it the filename of a
previously-saved plan file.

The terraform apply command executes the actions proposed in a Terraform plan.

-auto-approve: Skips interactive approval of the plan before applying. This option is ignored when you pass
a previously-saved plan file because Terraform considers you passing the plan file as the approval and so
will never prompt in that case.

-compact-warnings: This shows any warning messages in a compact form which includes only the summary
messages unless the warnings are accompanied by at least one error and thus the warning text might be
useful context for the errors.

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 5/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

-input=false:Flat
Disables all of Terraform’s interactive prompts. Note that this also prevents Terraform from
25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now
prompting for interactive approval of a plan, so Terraform will conservatively assume that you do not wish to
apply the plan, causing the operation to fail. If you wish to run Terraform in a non-interactive context, see
Running Terraform in Automation for some different approaches.

-lock=false: Disables Terraform’s default behavior of attempting to take a read/write lock on the state for the
duration of the operation.

-lock-timeout=DURATION: Unless locking is disabled with -lock=false, instructs Terraform to retry acquiring a
lock for a period of time before returning an error. A duration syntax is a number followed by a time unit
letter, such as “3s” for three seconds.

-no-color: Disables terminal formatting sequences in the output. Use this if you are running Terraform in a
context where its output will be rendered by a system that cannot interpret terminal formatting.

-parallelism=n: Limit the number of concurrent operations as Terraform walks the graph. Defaults to 10.

For configurations using the local backend only, terraform apply also accepts the legacy options -state, -
state-out, and -backup.

Q 14. What is the default number of concurrent operations supported by terraform


apply command?
A. 100

B. 10

C. 5

D. 1

Answer – B

The default number of concurrent operations supported by Terraform apply command is 10.

-parallelism=n – Limit the number of concurrent operations as Terraform walks the graph and the default is
10

Q 15. You are trying to login into Terraform Enterprise. Which of the following
command is used to save the API token?
A. terraform get

B. terraform API-get

C. terraform login

D. terraform cloud – get api

Answer – C

terraform login command can be used to automatically obtain and save an API token for Terraform Cloud,
Terraform Enterprise, or any other host that offers Terraform services.

By default, Terraform will obtain an API token and save it in plain text in a local CLI configuration file called
credentials.tfrc.json. When you run terraform login, it will explain specifically where it intends to save the
API token and give you a chance to cancel if the current configuration is not as desired.

The syntax for Terraform login:

terraform login [hostname]

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 6/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

If you don’t Flat


provide
25%an
offexplicit
on GCP hostname, Terraform
courses | Full will assume
Training Package | Useyou wantWHIZ25GCP
Coupon: to log in to| Terraform
Enroll NowCloud at
app.terraform.io.

Q 16. What are the two supported backend types in Terraform?


A. Remote-backend

B. Enhanced

C. Local- backend

D. Standard

Answer B, D

Terraform’s backends are divided into two main types, according to how they handle state and operations:

Enhanced backends can both store state and perform operations. There are only two enhanced backends:
local and remote.
Standard backends only store state and rely on the local backend for performing operations.

Q 17. Is terraform state-unlock command used to unlock the locked state file?
A. True

B. False

Answer: False

The correct command is given below-

terraform force-unlock [options] LOCK_ID [DIR]

The above command is used to unlock the state file.

Q 18. SMB(Server Message Block) and RDP(Remote Desktop) are supported


connection types in the remote-exec provisioner. True or False?
A. True

B. False

Answer: False

Ssh and winrm are the supported connection types in remote-exec provisioner but not SMB and RDP.

Q 19. Community providers are downloaded automatically using terraform init


command. True or False?
A. True

B. False

Answer: True

Any community provider can be automatically downloaded from a Terraform registry by running the

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 7/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

terraform init command.

Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now
Community providers are installed in the same way as other providers

Q 20. By using the count meta-argument, you can scale the resources by
incrementing the number.
A. True

B. False

Answer: True

The count is one of the reserved words. One can use count for scaling instead of repeating the resources
again.

The count meta-argument accepts a whole number and creates that many instances of the resource or
module.

Q 21. A user wants to list all resources which are deployed using Terraform. How can
this be done?
A. terraform state show

B. terraform state list

C. terraform show

D. terraform show list

Answer: B

Option A is INCORRECT because this command shows the attributes of a single resource in the Terraform
state file
Option B is CORRECT because the terraform state list command is used to list resources within a
Terraform state.
Option C is INCORRECT because this command will output all resources and attributes in a human-
readable format.
Option D is INCORRECT because this option will try to display all resources and attributes in the list file.
This command takes the list as an input file for the show command.

The command will list all resources in the state file matching the given addresses (if any). If no addresses
are given, all resources are listed.

The resources listed are sorted according to module depth order followed by alphabetical. This means
that resources that are in your immediate configuration are listed first, and resources that are more
deeply nested within modules are listed last.

For complex infrastructures, the state can contain thousands of resources it can filter using the id option.

Q 22. Which among the following log command should be set to get Maximum
verbosity of terraform logs?

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 8/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

A. set the TF_LOG=DEBUG


Flat 25% off on in
GCPenvironment
courses | Fullvariable

Training Package | Use Coupon: WHIZ25GCP | Enroll Now


B. set the TF_LOG=INFO in environment variable

C. set the TF_LOG=TRACE in environment variable

D. set the TF_LOG=WARN in environment variable

Answer: C

Option A is INCORRECT because this command will not give detailed verbose information compared to
trace
Option B is INCORRECT because this command will just give info but will output detailed information.
Option C is CORRECT because this command will output more verbose information compared all other
options.
Option D is INCORRECT because this option will only print warn messages.

Terraform has detailed logs which can be enabled by setting the TF_LOG environment variable to any
value. This will cause detailed logs to appear on stderr.

To persist logged output you can set TF_LOG_PATH in order to force the log to always be appended to a
specific file when logging is enabled. Note that even when TF_LOG_PATH is set, TF_LOG must be set in
order for any logging to be enabled.

Q 23. Which among the following are not module source options?
A. Local Path

B. Terraform registry

C. Bit bucket

D. HTTP URLs

E. BLOB storage

Answer: E

Options A, B, C, and D are INCORRECT because these are valid source options for a module.

Option E is CORRECT because we cannot use BLOB storage as a module source option.

The source argument in a module block tells Terraform where to find the source code for the desired child
module. Terraform uses this during the module installation step of terraform init to download the source
code to a directory on a local disk so that it can be used by other Terraform commands.

Currently following are the valid source options for a module:

Local Paths
Terraform Registry
Github
Bitbucket
Generic Git, Mercurial repositories
HTTP URLs
S3 buckets
GCS buckets

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 9/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

Q 24. Which of the


Flat 25% following
off on GCP coursescommand can
| Full Training be used
Package to syntactically
| Use Coupon: WHIZ25GCP |check to
Enroll Now
terraform configuration before using apply or plan command?
A. terraform fmt

B. terraform validate

C. terraform show

D. terraform check

Answer: B

Option A is INCORRECT because fmt is used to rewrite Terraform configuration files to a canonical format
and style.

Option B is CORRECT because it is used to validate the terraform configuration.

Option C is INCORRECT because the show is used to provide human-readable output from a state or plan
file.

Option D is INCORRECT because there is no command in terraform called to check.

terraform validate command checks whether a configuration is syntactically valid and internally consistent,
regardless of any provided variables or existing state.

Validation requires an initialized working directory with any referenced plugins and modules installed.

Q 25. When multiple team members are working on the same state file, the state file
gets locked. How to remove the lock?
A. terraform force-unlock LOCK_ID

B. terraform force-unlock STATE_FILE

C. terraform unlock LOCK_ID

D. terraform force-unlock=true

Answer: A

Option A is CORRECT force-unlock with LOCK_ID is used to remove lock on state file.
Option B is INCORRECT because we need to pass LOCK_ID as argument not STATE_FILE.
Option C is INCORRECT because force-unlock is used not unlock is used to remove state lock.
Option D is INCORRECT because force-unlock needs LOCK_ID as an argument.

force-unlock manually unlock the state for the defined configuration. This will not modify your
infrastructure. This command removes the lock on the state for the current configuration. The behavior of
this lock is dependent on the backend being used.

Local state files cannot be unlocked by another process. Usage: terraform force-unlock LOCK_ID [DIR]

Conclusion:

This set of 25 free questions help you build an understanding of the exam pattern but not enough. To take
the Terraform associate exam you may have to attempt some more practice questions. You can also sign up
for a Terraform Demo environment in case your company is not using Terraform right now.

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 10/11
05/09/2022 11:22 Terraform Certification Exam -25 Free Practice Questions

Reference Links:
Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now

https://docs.hashicorp.com/sentinel/concepts/policy-as-code/
https://www.hashicorp.com/certification/terraform-associate
https://www.terraform.io/docs/cli/commands/plan.html

 About the Author  More from Author

About Jeevitha TP
Jeevitha has a proven experience with a solid understanding of SEO activities such as
content strategy, link building, and keyword strategy to increase rankings on all major
search networks.
Further, she works closely with the editorial and marketing teams to
drive SEO in content creation and programming.

https://www.whizlabs.com/blog/terraform-certification-exam-questions/ 11/11

You might also like