Terraform Exam
Terraform Exam
Question #1 Topic 1
A. True
B. False
Correct Answer: B
Reference:
https://www.terraform.io/docs/language/state/index.html
One remote backend con guration always maps to a single remote workspace.
A. True
B. False
Correct Answer: A
Reference:
https://www.terraform.io/docs/language/settings/backends/remote.html
Question #3 Topic 1
How is the Terraform remote backend different than other state backends such as S3, Consul, etc.?
Correct Answer: A
If you and your team are using Terraform to manage meaningful infrastructure, we recommend using the remote backend with Terraform Cloud
or Terraform
Enterprise.
Reference:
https://www.terraform.io/docs/language/settings/backends/index.html
A. terraform plan to import the current infrastructure to the state le, make code changes, and terraform apply to update the infrastructure.
B. Write a Terraform con guration, run terraform show to view proposed changes, and terraform apply to create new infrastructure.
C. terraform import to import the current infrastructure to the state le, make code changes, and terraform apply to update the infrastructure.
D. Write a Terraform con guration, run terraform init, run terraform plan to view planned infrastructure changes, and terraform apply to create
new infrastructure.
Correct Answer: D
Question #5 Topic 1
A. True
B. False
Correct Answer: A
Reference:
https://github.com/hashicorp/terraform/issues/17928
Question #6 Topic 1
You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script.
Which of the following commands would you use rst?
Correct Answer: A
A. remote-exec
B. null-exec
C. local-exec
D. le
Correct Answer: A
The remote-exec provisioner invokes a script on a remote resource after it is created.
Reference:
https://www.terraform.io/docs/language/resources/provisioners/remote-exec.html
Question #8 Topic 1
D. Major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers
Correct Answer: D
Reference:
https://jayendrapatil.com/terraform-cheat-sheet/#Terraform_Read_and_write_con guration
Question #9 Topic 1
What command does Terraform require the rst time you run it within a con guration directory?
A. terraform import
B. terraform init
C. terraform plan
D. terraform workspace
Correct Answer: B
terraform init command is used to initialize a working directory containing Terraform con guration les.
Reference:
https://www.terraform.io/docs/cli/commands/init.html
You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code.
What is the best method to quickly nd the IP address of the resource you deployed?
B. In a new folder, use the terraform_remote_state data source to load in the state le, then write an output for each resource that you nd the
state le
C. Run terraform state list to nd the name of the resource, then terraform state show to nd the attributes including public IP address
D. Run terraform destroy then terraform apply and look for the IP address in stdout
Correct Answer: A
Reference:
https://www.terraform.io/docs/cli/commands/output.html
A. Versioned infrastructure
B. Golden images
C. Idempotence
D. Self-describing infrastructure
Terraform variables and outputs that set the "description" argument will store that description in the state le.
A. True
B. False
Correct Answer: A
A. vpc
B. main
C. aws
D. test
Correct Answer: C
Reference:
https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-types.html
If you manually destroy infrastructure, what is the best practice re ecting this change in Terraform?
Correct Answer: B
A. State le
B. Con guration le
C. Credentials
D. Cloud provider
Correct Answer: CD
Reference:
https://www.terraform.io/docs/cli/commands/refresh.html
What information does the public Terraform Module Registry automatically expose about published modules?
C. Outputs
Correct Answer: E
Reference:
https://www.terraform.io/docs/registry/modules/publish.html
If a module uses a local values, you can expose that value with a terraform output.
A. True
B. False
Correct Answer: A
Output values are like function return values.
Reference:
https://www.terraform.io/docs/language/values/locals.html
https://www.terraform.io/docs/language/values/outputs.html
You should store secret data in the same version control repository as your Terraform con guration.
A. True
B. False
Correct Answer: B
Reference:
https://blog.gruntwork.io/a-comprehensive-guide-to-managing-secrets-in-your-terraform-code-1d586955ace1
A. split
B. join
C. slice
D. chomp
Correct Answer: D
Reference:
https://www.terraform.io/docs/language/functions/chomp.html
You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are
standardizing with
Terraform and want to manage these VMs using Terraform instead.
What are the two things you must do to achieve this? (Choose two.)
Correct Answer: BD
The terraform import command is used to import existing infrastructure.
Import existing Google Cloud resources into Terraform with Terraformer.
Reference:
https://www.terraform.io/docs/cli/import/usage.html
https://cloud.google.com/docs/terraform
You have recently started a new job at a retailer as an engineer. As part of this new role, you have been tasked with evaluating multiple outages
that occurred during peak shopping time during the holiday season. Your investigation found that the team is manually deploying new compute
instances and con guring each compute instance manually. This has led to inconsistent con guration between each compute instance.
How would you solve this using infrastructure as code?
A. Implement a ticketing work ow that makes engineers submit a ticket before manually provisioning and con guring a resource
B. Implement a checklist that engineers can follow when con guring compute instances
C. Replace the compute instance type with a larger version to reduce the number of required deployments
D. Implement a provisioning pipeline that deploys infrastructure con gurations committed to your version control system following code
reviews
Correct Answer: A
A. True
B. False
Correct Answer: A
Which two steps are required to provision new infrastructure in the Terraform work ow? (Choose two.)
A. Destroy
B. Apply
C. Import
D. Init
E. Validate
Correct Answer: BD
Reference:
https://www.terraform.io/guides/core-work ow.html
A. When you want to force Terraform to destroy a resource on the next apply
B. When you want to force Terraform to destroy and recreate a resource on the next apply
D. When you want Terraform to destroy all the infrastructure in your workspace
Correct Answer: B
The terraform taint command manually marks a Terraform-managed resource as tainted, forcing it to be destroyed and recreated on the next
apply.
Reference:
https://www.terraform.io/docs/cli/commands/taint.html
A. True
B. False
Correct Answer: B
Reference:
https://www.terraform.io/docs/extend/guides/v1-upgrade-guide.html
A. You see a status message that you cannot acquire the lock
Correct Answer: C
Manually unlock the state for the de ned con guration.
Reference:
https://www.terraform.io/docs/cli/commands/force-unlock.html
Terraform can import modules from a number of sources `" which of the following is not a valid source?
A. FTP server
B. GitHub repository
C. Local path
Correct Answer: A
Which of the following is available only in Terraform Enterprise or Cloud workspaces and not in Terraform CLI?
Correct Answer: A
A. True
B. False
Correct Answer: A
The terraform validate command validates the syntax and arguments of the Terraform con guration les.
Reference:
https://www.terraform.io/docs/cli/code/index.html
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 con guration. To be safe, you would like to rst 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.)
B. This is not possible. You can only show resources that will be created.
D. Run terraform destroy and it will rst output all the resources that will be deleted before prompting for approval.
Correct Answer: CD
Reference:
https://www.terraform.io/docs/cli/commands/state/rm.html
Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers?
A. servers = num_servers
B. servers = variable.num_servers
C. servers = var(num_servers)
D. servers = var.num_servers
Correct Answer: A
A. True
B. False
Correct Answer: A
Most provisioners require access to the remote resource via SSH or WinRM, and expect a nested connection block with details about how to
connect.
Reference:
https://www.terraform.io/docs/language/resources/provisioners/connection.html
Terraform can run on Windows or Linux, but it requires a Server version of the Windows operating system.
A. True
B. False
Correct Answer: B
A. tfplan les
B. Terraform binary
C. Provider plugins
D. State le
Correct Answer: D
The local backend stores state on the local lesystem, locks that state using system APIs, and performs operations locally.
Reference:
https://www.terraform.io/docs/language/settings/backends/local.html
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 Con guration Language) code according to standard Terraform style convention?
A. Run the terraform fmt command during the code linting phase of your CI/CD process
B. Designate one person in each team to review and format everyone's code
C. Manually apply two spaces indentation and align equal sign "=" characters in every Terraform le (*.tf)
D. Write a shell script to transform Terraform les using tools such as AWK, Python, and sed
Correct Answer: C
Indent two spaces for each nesting level.
When multiple arguments with single-line values appear on consecutive lines at the same nesting level, align their equals signs.
Reference:
https://www.terraform.io/docs/language/syntax/style.html
What value does the Terraform Cloud/Terraform Enterprise private module registry provide over the public Terraform Module Registry?
A. The ability to share modules with public Terraform users and members of Terraform Enterprise Organizations
Correct Answer: D
Terraform Registry is an index of modules shared publicly using this protocol. This public registry is the easiest way to get started with
Terraform and nd modules created by others in the community.
Reference:
https://www.terraform.io/docs/language/modules/sources.html
A. Sources all providers present in the con guration and ensures they are downloaded and available locally
Correct Answer: D
Reference:
https://www.terraform.io/docs/cli/commands/init.html
You have declared a variable called var.list which is a list of objects that all have an attribute id.
Which options will produce a list of the IDs? (Choose two.)
B. var.list[*].id
C. [ var.list[*].id ]
Correct Answer: AB
A. type
B. default
C. description
Correct Answer: B
The variable declaration can also include a default argument.
Reference:
https://www.terraform.io/docs/language/values/variables.html
When using a module block to reference a module stored on the public Terraform Module Registry such as:
A. Modules stored on the public Terraform Module Registry do not support versioning
D. Nothing €" modules stored on the public Terraform Module Registry always default to version 1.0.0
Correct Answer: C
What features does the hosted service Terraform Cloud provide? (Choose two.)
B. Automatic backups
Correct Answer: BC
Reference:
https://www.terraform.io/docs/enterprise/admin/automated-recovery.html https://www.terraform.io/docs/language/state/remote.html
B. In the terraform le
C. In the terraform.tfstate le
Correct Answer: C
The local backend stores state on the local lesystem, locks that state using system APIs, and performs operations locally.
Reference:
https://www.terraform.io/docs/language/settings/backends/local.html
Which option can not be used to keep secrets out of Terraform con guration les?
A. A Terraform provider
B. Environment variables
C. A -var ag
D. secure string
Correct Answer: C
Reference:
https://secrethub.io/blog/secret-management-for-terraform/
Correct Answer: A
Reference:
https://github.com/hashicorp/terraform/issues/19291
A. True
B. False
Correct Answer: B
Examine the following Terraform con guration, which uses the data source for an AWS AMI.
What value should you enter for the ami argument in the AWS instance resource?
A. aws_ami.ubuntu
B. data.aws_ami.ubuntu
C. data.aws_ami.ubuntu.id
D. aws_ami.ubuntu.id
Correct Answer: C
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
Reference:
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
FILL BLANK -
You need to specify a dependency manually.
What resource meta-parameter can you use to make sure Terraform respects the dependency?
Type your answer in the eld provided. The text eld is not case-sensitive and all variations of the correct answer are accepted.
You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account
already contains
15 virtual machines (VM). You develop a Terraform con guration containing one VM, perform terraform apply, and see that your VM was created
successfully.
What should you do to delete the newly-created VM with Terraform?
A. The Terraform state le contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM.
B. The Terraform state le only contains the one new VM. Execute terraform destroy.
D. Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state le.
Correct Answer: B
A. dev
B. azurerm_resource_group
C. azurerm
D. test
Correct Answer: A
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into syslog.
A. True
B. False
Correct Answer: A
Reference:
https://www.terraform.io/docs/internals/debugging.html
Correct Answer: A
Backends are con gured with a nested backend block within the top-level terraform block.
Reference:
https://www.terraform.io/docs/language/settings/backends/con guration.html
In Terraform 0.13 and above, outside of the required_providers block, Terraform con gurations always refer to providers by their local names.
A. True
B. False
Correct Answer: A
Outside of the required_providers block, Terraform con gurations always refer to providers by their local names.
Reference:
https://www.terraform.io/docs/language/providers/requirements.html
What command should you run to display all workspaces for the current con guration?
A. terraform workspace
Correct Answer: C
terraform workspace list
The command will list all existing workspaces.
Reference:
https://www.terraform.io/docs/cli/commands/workspace/list.html
A. True
B. False
Correct Answer: B
Terraform con gurations must declare which providers they require, so that Terraform can install and use them.
Reference:
https://www.terraform.io/docs/language/providers/con guration.html
Which of these is the best practice to protect sensitive values in state les?
A. Blockchain
Correct Answer: C
Use of remote backends and especially the availability of Terraform Cloud, there are now a variety of backends that will encrypt state at rest and
will not store the state in cleartext on machines running.
Reference:
https://www.terraform.io/docs/extend/best-practices/sensitive-state.html
A. Immediately
Correct Answer: B
How would you reference the "name" value of the second instance of this ctitious resource?
A. element(aws_instance.web, 2)
B. aws_instance.web[1].name
C. aws_instance.web[1]
D. aws_instance.web[2].name
E. aws_instance.web.*.name
Correct Answer: A
Reference:
https://www.terraform.io/docs/con guration-0-11/interpolation.html
Correct Answer: D
Reference:
https://www.terraform.io/docs/con guration-0-11/providers.html
A. True
B. False
Correct Answer: A
Reference:
https://www.terraform.io/docs/language/resources/provisioners/syntax.html
C. State le drift
Correct Answer: C
Reference:
https://www.hashicorp.com/blog/detecting-and-managing-drift-with-terraform
FILL BLANK -
Which ag would you add to terraform plan to save the execution plan to a le?
Type your answer in the eld provided. The text eld is not case-sensitive and all variations of the correct answer are accepted.
FILL BLANK -
What is the name of the default le where Terraform stores the state?
Type your answer in the eld provided. The text eld is not case-sensitive and all variations of the correct answer are accepted.
A. True
B. False
Correct Answer: A
Reference:
https://www.terraform.io/docs/con guration-0-11/locals.html
A. list
B. map
C. tree
D. set
Correct Answer: C
Reference:
https://www.terraform.io/docs/language/expressions/type-constraints.html
When running the command terraform taint against a managed resource you want to force recreation upon, Terraform will immediately destroy
and recreate the resource.
A. True
B. False
Correct Answer: B
Reference:
https://www.devopsschool.com/blog/terraform-taint-and-untaint-explained-with-example-programs-and-tutorials/
All standard backend types support state storage, locking, and remote operations like plan, apply and destroy.
A. True
B. False
Correct Answer: A
Reference:
https://www.terraform.io/docs/language/settings/backends/remote.html
A. Validates your expectations against the execution plan without permanently modifying state
B. Initializes your working directory containing your Terraform con guration les
D. Reconciles Terraform's state against deployed resources and permanently modi es state using the current status of deployed resources
Correct Answer: A
Reference:
https://github.com/hashicorp/terraform/issues/19235
You would like to reuse the same Terraform con guration for your development and production environments with a different state le for each.
Which command would you use?
A. terraform import
B. terraform workspace
C. terraform state
D. terraform init
Correct Answer: B
A. compute_instance
B. main
C. google
D. teat
Correct Answer: B
You're building a CI/CD (continuous integration/ continuous delivery) pipeline and need to inject sensitive variables into your Terraform run.
How can you do this safely?
Correct Answer: B
Your security team scanned some Terraform workspaces and found secrets stored in a plaintext in state les.
How can you protect sensitive data stored in Terraform state les?
Correct Answer: B
Reference:
https://www.terraform.io/docs/language/state/sensitive-data.html
In contrast to Terraform Open Source, when working with Terraform Enterprise and Cloud Workspaces, conceptually you could think about them as
completely separate working directories.
A. True
B. False
Correct Answer: A
You want to know from which paths Terraform is loading providers referenced in your Terraform con guration (*.tf les). You need to enable
debug messages to nd this out.
Which of the following would achieve this?
B. Set verbose logging for each provider in your Terraform con guration
Correct Answer: A
Reference:
https://www.terraform.io/docs/cli/con g/environment-variables.html
D. By an explicit call
Correct Answer: D
You have a simple Terraform con guration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created
successfully.
What will happen if you delete the VM using the cloud provider console, and run terraform apply again without changing any Terraform code?
Correct Answer: D
Which of these options is the most secure place to store secrets foe connecting to a Terraform remote backend?
D. None of above
Correct Answer: A
Your DevOps team is currently using the local backend for your Terraform con guration. You would like to move to a remote backend to begin
storing the state le in a central location.
Which of the following backends would not work?
A. Amazon S3
B. Artifactory
C. Git
D. Terraform Cloud
Correct Answer: A
Reference:
https://secrethub.io/blog/secret-management-for-terraform/
A. Terraform Cloud
B. Consul
C. Remote
D. Local
Correct Answer: D
Reference:
https://www.terraform.io/docs/language/settings/backends/con guration.html
When you initialize Terraform, where does it cache modules from the public Terraform Module Registry?
B. In memory
Correct Answer: C
Reference:
https://www.terraform.io/docs/language/modules/sources.html
You write a new Terraform con guration and immediately run terraform apply in the CLI using the local backend.
Why will the apply fail?
A. Terraform needs you to format your code according to best practices rst
C. The Terraform CLI needs you to log into Terraform cloud rst
Correct Answer: C
What features stops multiple admins from changing the Terraform state at the same time?
A. Version control
B. Backend types
C. Provider constraints
D. State locking
Correct Answer: D
Reference:
https://blog.gruntwork.io/how-to-manage-terraform-state-28f5697e68fa
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?
Correct Answer: B
Reference:
https://www.terraform.io/docs/cli/commands/state/rm.html
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
A. True
B. False
Correct Answer: A
Reference:
https://learn.hashicorp.com/tutorials/terraform/dependencies?in=terraform/0-13
A. change
B. destroy
C. provision
D. import
Correct Answer: D
Correct Answer: B
Reference:
https://github.com/hashicorp/terraform-provider-null/issues/31
You just scaled your VM infrastructure and realized you set the count variable to the wrong value. You correct the value and save your change.
What do you do next to make your infrastructure match your con guration?
Correct Answer: A
Terraform provisioners that require authentication can use the ______ block.
A. connection
B. credentials
C. secrets
D. ssh
Correct Answer: B
Terraform validate reports syntax check errors from which of the following scenarios?
Correct Answer: B
Reference:
http://man.hubwiz.com/docset/Terraform.docset/Contents/Resources/Documents/docs/commands/validate.html
A. count
B. name
C. source
D. version
Correct Answer: B
Reference:
https://www.terraform.io/docs/language/values/variables.html
What type of block is used to construct a collection of nested con guration blocks?
A. for_each
B. repeated
C. nesting
D. dynamic
Correct Answer: D
Reference:
https://www.hashicorp.com/blog/hashicorp-terraform-0-12-preview-for-and-for-each
Module variable assignments are inherited from the parent module and do not need to be explicitly set.
A. True
B. False
Correct Answer: B
Reference:
https://github.com/hashicorp/terraform/issues/15818
If writing Terraform code that adheres to the Terraform style conventions, how would you properly indent each nesting level compared to the one
above it?
B. With a tab
Correct Answer: D
Reference:
https://www.terraform.io/docs/language/syntax/style.html
Correct Answer: A
Reference:
https://www.terraform.io/docs/cli/init/index.html
A. True
B. False
Correct Answer: B
Reference:
https://www.packer.io/docs/templates/hcl_templates/functions
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
A. Only Terraform Cloud organization owners can set workspace variables on VCS connected workspaces
B. Commit a change to the VCS working directory and branch that the Terraform Cloud workspace is connected to
C. Only members of a VCS organization can open a pull request against repositories that are connected to Terraform Cloud workspaces
D. Only Terraform Cloud organization owners can approve plans in VCS connected workspaces
Correct Answer: B
Reference:
https://www.terraform.io/docs/cloud/vcs/index.html
Terraform and Terraform providers must use the same major version number in a single con guration.
A. True
B. False
Correct Answer: B
Reference:
https://www.terraform.io/docs/language/expressions/version-constraints.html
Correct Answer: D
When using Terraform to deploy resources into Azure, which scenarios are true regarding state les? (Choose two.)
A. When a change is made to the resources via the Azure Cloud Console, the changes are recorded in a new state le
B. When a change is made to the resources via the Azure Cloud Console, Terraform will update the state le to re ect them during the next
plan or apply
C. When a change is made to the resources via the Azure Cloud Console, the current state le will not be updated
D. When a change is made to the resources via the Azure Cloud Console, the changes are recorded in the current state le
Correct Answer: AC
You need to deploy resources into two different cloud regions in the same Terraform con guration. To do that, you declare multiple provider
con gurations as follows:
What meta-argument do you need to con gure in a resource block to deploy the resource to the `us-west-2` AWS region?
A. alias = west
B. provider = west
C. provider = aws.west
D. alias = aws.west
Correct Answer: C
Reference:
https://github.com/hashicorp/terraform/issues/451
You have declared an input variable called environment in your parent module. What must you do to pass the value to a child module in the
con guration?
Correct Answer: C
If a module declares a variable with a default, that variable must also be de ned within the module.
A. True
B. False
Correct Answer: A
Which option cannot be used to keep secrets out of Terraform con guration les?
A. Environment Variables
C. A Terraform provider
D. A -var ag
Correct Answer: D
Which of the following arguments are required when declaring a Terraform output?
A. sensitive
B. description
C. default
D. value
Correct Answer: D
Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Enterprise
automatically and proactively enforce this security control?
B. By adding variables to each TFE workspace to ensure these settings are always enabled
Correct Answer: B
A. API
B. VCS Systems
C. Shell scripts
Correct Answer: A
terraform validate validates that your infrastructure matches the Terraform state le.
A. True
B. False
Correct Answer: A
Correct Answer: C
FILL BLANK -
In the below con guration, how would you reference the module output vpc_id?
Type your answer in the eld provided. The text eld is not case sensitive and all variations of the correct answer are accepted.
How would you reference the Volume IDs associated with the ebs_block_device blocks in this con guration?
A. aws_instance.example.ebs_block_device.[*].volume_id
B. aws_instance.example.ebs_block_device.volume_id
C. aws_instance.example.ebs_block_device[sda2,sda3].volume_id
D. aws_instance.example.ebs_block_device.*.volume_id
Correct Answer: C
Correct Answer: B
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
Correct Answer: B
A module can always refer to all variables declared in its parent module.
A. True
B. False
Correct Answer: A
When you use a remote backend that needs authentication, HashiCorp recommends that you:
A. Use partial con guration to load the authentication credentials outside of the Terraform code
Correct Answer: B
You have a simple Terraform con guration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created
successfully.
What will happen if you terraform apply again immediately afterwards without changing any Terraform code?
D. Nothing
Correct Answer: C
A junior admin accidentally deleted some of your cloud instances. What does Terraform do when you run terraform apply?
Correct Answer: D
You have created a main.tr Terraform con guration consisting of an application server, a database, and a load balancer. You ran terraform apply
and all resources were created successfully. Now you realize that you do not actually need the load balancer so you run terraform destroy without
any ags What will happen?
A. Terraform will destroy the application server because it is listed rst in the code
B. Terraform will prompt you to con rm that you want to destroy all the infrastructure
D. Terraform will prompt you to pick which resource you want to destroy
Correct Answer: B
Which type of block fetches or computes information for use elsewhere in a Terraform con guration?
A. provider
B. resource
C. local
D. data
Correct Answer: A
You have just developed a new Terraform con guration for two virtual machines with a cloud provider. You would like to create the infrastructure
for the rst time.
Which Terraform command should you run rst?
A. terraform apply
B. terraform plan
C. terraform show
D. terraform init
Correct Answer: C
All modules published on the o cial Terraform Module Registry have been veri ed by HashiCorp.
A. True
B. False
Correct Answer: B
A. True
B. False
Correct Answer: B
Which of the following does terraform apply change after you approve the execution plan? (Choose two.)
A. Cloud infrastructure
D. State le
E. Terraform code
Correct Answer: C
A Terraform backend determines how Terraform loads state and stores updates when you execute ___________.
A. apply
B. taint
C. destroy
Correct Answer: E
B. There is no such le
Correct Answer: D
You've used Terraform to deploy a virtual machine and a database. You want to replace this virtual machine instance with an identical one without
affecting the database. What is the best way to achieve this using Terraform?
B. Use the terraform taint command targeting the VMs then run terraform plan and terraform apply
D. Delete the Terraform VM resources from your Terraform code then run terraform plan and terraform apply
Correct Answer: B
How do you specify a module's version when publishing it to the public Terraform Module Registry?
Correct Answer: C
A. True
B. False
Correct Answer: A
To check if all code in a Terraform con guration with multiple modules is properly formatted without making changes, what command should be
run?
Correct Answer: C
As a member of the operations team, you need to run a script on a virtual machine created by Terraform. Which provision is best to use in your
Terraform code?
A. null-ex
B. local-exec
C. remote-exec
D. le
Correct Answer: B
You are using a networking module in your Terraform con guration with the name label my_network. In your main con guration you have the
following code:
When you run terraform validate, you get the following error:
What must you do to successfully retrieve this value from your networking module?
Correct Answer: D
You are writing a child Terraform module which provisions an AWS instance. You want to make use of the IP address returned in the root
con guration. You name the instance resource "main".
Which of these is the correct way to de ne the output value using HCL2?
A.
B.
Correct Answer: A
How can a ticket-based system slow down infrastructure provisioning and limit the ability to scale? (Choose two.)
A. A full audit trail of the request and ful llment process is generated
D. A catalog of approved resources can be accessed from drop down lists in a request form
Correct Answer: B
Correct Answer: C
Which Terraform collection type should you use to store key/value pairs?
A. tuple
B. set
C. ma€
D. list
Correct Answer: C
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 con guration. To be safe, you would like to rst 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.)
C. Run terraform destroy and it will rst output all the resources that will be deleted before prompting for approval
Correct Answer: AD
Correct Answer: D
A. True
B. False
Correct Answer: A
What advantage does an operations team that uses infrastructure as code have?
Correct Answer: D
You have modi ed your Terraform con guration to x a typo in the Terraform ID of a resource from aws_security_group.http to
aws_security_group.http
Which of the following commands would you run to update the ID in state without destroying the resource?
B. terraform apply
C. terraform refresh
Correct Answer: B
You are creating a Terraform con guration which needs to make use of multiple providers, one for AWS and one for Datadog.
Which of the following provider blocks would allow you to do this?
A.
B.
C.
Correct Answer: B
Question #140 Topic 1
A. True
B. False
Correct Answer: B
A. True
B. False
Correct Answer: B
B. Running terraform destroy from the correct directory and then typing "yes" when prompted in the CLI
Correct Answer: D
Correct Answer: B
You're writing a Terraform con guration that needs to read input from a local le called id_rsa.pub.
Which built-in Terraform function can you use to import the le's contents as a string?
A. leset("id_rsa.pub")
B. lebase64("id_rsa.pub")
C. template le("id_rsa.pub")
D. le("id_rsa.pub")
Correct Answer: A
E. Group a collection of Terraform con guration les that map to a single state le
You can reference a resource created with for_each using a Splat (*) expression.
A. True
B. False
Correct Answer: B
A. Terraform automatically builds a resource graph based on resources, provisioners, special meta-parameters, and the state le, if present.
B. Terraform requires all dependencies between resources to be speci ed using the depends_on parameter
C. Terraform requires resources in a con guration to be listed in the order they will be created to determine dependencies
Correct Answer: A
A. Path
B. Provider
C. Resource ID
D. Resource address
Correct Answer: BC
Once a new Terraform backend is con gured with a Terraform code block, which command(s) is (are) used to migrate the state le?
A. terraform apply
B. terraform push
D. terraform init
Correct Answer: D
A. Requires any version of the AWS provider >= 3.0 and < 4.0
C. Requires any version of the AWS provider after the 3.0 major release, like 4.1
Correct Answer: A
B. Your state le
Correct Answer: B
Which of the following is not valid source path for specifying a module?
A. source = "./modulelversion=v1.0.0"
B. source = "github.com/hashicorp/example?ref=v1.0.0"
C. source = "./module"
D. source = "hashicorp/consul/aws"
Correct Answer: A
C. Depending on provider speci cation, Terraform may need to destroy and recreate your infrastructure resources
D. By default, it does not refresh your state le to re ect current infrastructure con guration
Correct Answer: AC
Correct Answer: C
Which of the following is true about Terraform's implementation of infrastructure as code? (Choose two.)
Correct Answer: BD
You need to write some Terraform code that adds 42 rewall rules to a security group as shown in the example.
What can you use to avoid writing 42 different nested ingress con g blocks by hand?
A. A count loop
B. A for block
D. A dynamic block
Correct Answer: D
Which of the following is the safest way to inject sensitive values into a Terraform Cloud workspace?
B. Set a value for the variable in the UI and check the "Sensitive" check box
D. Set the variable value on the command line with the -var ag
Correct Answer: B
terraform apply will fail if you have not am terraform plan rst to update the plan output.
A. True
B. False
Correct Answer: B
How would you reference the attribute "name" of this ctitious resource in HCL?
A. resource.kubernetes_namespace.example.name
B. kubernetes_namespace.test.name
C. kubernetes_namespace.example.name
D. data.kubernetes_namespace.name
Correct Answer: C
A Terraform output that sets the "sensitive" argument to true will not store that value in the state le.
A. True
B. False
Correct Answer: B
Which are forbidden actions when the Terraform state le is locked? (Choose three.)
A. terraform destroy
B. terraform fmt
D. terraform apply
E. terraform plan
F. terraform validate
A. Plan
B. Init
C. Refresh
Correct Answer: B
When does Sentinel enforce policy logic during a Terraform Enterprise run?
Correct Answer: C
Correct Answer: A
Which is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example git::https://example.com/vpc.git)?
Correct Answer: A
Changing the Terraform backend from the default "local" backend to a different one after doing your rst terraform apply is:
A. Mandatory
B. Optional
C. Impossible
D. Discouraged
Correct Answer: B
You have modi ed your local Terraform con guration and ran terraform plan to review the changes. Simultaneously, your teammate manually
modi ed the infrastructure component you are working on. Since you already ran terraform plan locally, the execution plan for terraform apply will
be the same.
A. True
B. False
Correct Answer: B
terraform apply is failing with the following error. What next step should you take to determine the root cause of the problem?
Error loading state: AccessDenied: Access Denied status code: 403, request id: 288766CE5CCA24A0, host id: FOOBAR
A. Set TF_LOG=DEBUG
Correct Answer: A
As a member of an operations team that uses infrastructure as code (IaC) practices, you are tasked with making a change to an infrastructure
stack running in a public cloud.
Which pattern would follow IaC best practices for making a change?
A. Clone the repository containing your infrastructure code and then run the code
B. Use the public cloud console to make the change after a database record has been approved
E. Submit a pull request and wait for an approved merge of the proposed changes
Correct Answer: E
What command can you run to generate DOT (Document Template) formatted data to visualize Terraform dependencies?
A. terraform refresh
B. terraform show
C. terraform graph
D. terraform output
Correct Answer: C
Which provider authentication method prevents credentials from being stored in the state le?
Correct Answer: A
Running terraform fmt without any ags in a directory with Terraform con guration les will check the formatting of those les without changing
their contents.
A. True
B. False
Correct Answer: B
terraform init retrieves the source code for all referenced modules.
A. True
B. False
Correct Answer: A
You have a Terraform con guration that de nes a single virtual machine with no references to it. You have run terraform apply to create the
resource, and then removed the resource de nition from your Terraform con guration le.
What will happen when you run terraform apply in the working directory again?
A. Nothing
D. Terraform will remove the virtual machine from the state le, but the resource will still exist
Correct Answer: B
Correct Answer: D
In Terraform HCL, an object type of object({ name=string, age=number }) would match this value:
A.
B.
Correct Answer: B
A. Source code
B. Plugins directory
Correct Answer: A
Which of the following locations can Terraform use as a private source for modules? (Choose two.)
Correct Answer: AC
Why should secrets not be hard coded into Terraform code? (Choose two.)
B. Terraform code is typically stored in version control, as well as copied to the systems from which it's run. Any of those may not have robust
security mechanisms.
C. The Terraform code is copied to the target resources to be applied locally and could expose secrets if a target resource is compromised.
Correct Answer: BC
A. The resource will not be affected, but the provisioner will need to be applied again
Correct Answer: C
When should Terraform con guration les be written when running terraform import on existing infrastructure?
B. Terraform will generate the corresponding con guration les for you
C. You should write Terraform con guration les after the next terraform import is executed
Correct Answer: B
A. terraform env
B. terraform console
C. terraform test
D. terraform validate
Correct Answer: B
Reference:
https://www.terraform.io/language/functions
Why does this backend con guration not follow best practices?
B. You should use the local enhanced storage backend whenever possible
D. The backend con guration should contain multiple credentials so that more than one user can execute terraform plan and terraform apply
Correct Answer: A
Open source Terraform can only import publicly-accessible and open-source modules.
A. True
B. False
Correct Answer: A
B. Destroy all Terraform code les in the current directory while leaving the state le intact
Correct Answer: D
While attempting to deploy resources into your cloud provider using Terraform, you begin to see some odd behavior and experience sluggish
responses. In order to troubleshoot you decide to turn on Terraform debugging. Which environment variables must be con gured to make
Terraform's logging more verbose?
A. TF_LOG_LEVEL
B. TF_LOG_FILE
C. TF_LOG
D. TP_LOG_PATH
Correct Answer: C
Reference:
https://www.terraform.io/internals/debugging
If a DevOps team adopts AWS CloudFormation as their standardized method for provisioning public cloud resources, which of the following
scenarios poses a challenge for this team?
A. The team is asked to build a reusable code base that can deploy resources into any AWS region
B. The team is asked to manage a new application stack built on AWS-native services
C. The organization decides to expand into Azure and wishes to deploy new infrastructure using their existing codebase
Correct Answer: D
A. True
B. False
Correct Answer: B
Which of the following can you do with terraform plan? (Choose two.)
C. View the execution plan and check if the changes match your expectations
Correct Answer: AC
Reference:
https://learn.hashicorp.com/tutorials/terraform/plan
D. Docker les
Correct Answer: BC
FILL BLANK -
You need to migrate a workspace to use a remote backend. After updating your con guration, what command do you run to perform the
migration?
Type your answer in the eld provided. The text eld is not case-sensitive and all variations of the correct answer are accepted.
When using a module from the public Terraform Module Registry, the following parameters are required attributes in the module block. (Choose
two.)
Correct Answer: BE
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
Correct Answer: A
You can access state stored with the local backend by using the terraform_remote_state data source.
A. True
B. False
Correct Answer: B
You have been working in a Cloud provider account that is shared with other team members. You previously used Terraform to create a load
balancer that is listening on port 80. After some application changes, you updated the Terraform code to change the port to 443.
You run terraform plan and see that the execution plan shows the port changing from 80 to 443 like you intended, and step away to grab some
coffee.
In the meantime, another team member manually changes the load balancer port to 443 through the Cloud provider console before you get back to
your desk.
What will happen when you terraform apply upon returning to your desk?
A. Terraform will fail with an error because the state le is no longer accurate.
B. Terraform will change the load balancer port to 80, and then change it back to 443.
C. Terraform will not make any changes to the Load Balancer and will update the state le to re ect any changes made.
Correct Answer: C
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
B. False
Correct Answer: A
You have some Terraform code and a variable de nitions le named dev.auto.tfvars that you tested successfully in the dev environment. You want
to deploy the same code in the staging environment with a separate variable de nition le and a separate state le.
B. Write a new staging.auto.tfvars variable de nition le and run Terraform with the var- le=”staging.auto.tfvars” ag
E. Add new Terraform code (*.tf les) for staging in the same directory
Correct Answer: BC
B. Terraform core
C. Terraform provider
D. Terraform provisioner
Correct Answer: A
A. True
B. False
Correct Answer: B
Question #200 Topic 1
Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers in HCL2?
A. servers - var.num_servers
B. servers - num_servers
C. servers - var(num_servers)
D. $(var.num_servers)
Correct Answer: B
Which of the fallowing commands would you use to access all of the attributes and details of a resource managed by Terraform?
C. terraform get
Correct Answer: A
How would you be able to reference an attribute from the vsphere_datacenter data source for use with the datacenter_id argument within the
vsphere_folder resource in the following con guration?
A. data.dc.id
B. data.vsphere_datacenter.dc
C. vsphere_datacenter.dc.id
D. data.vsphere_datacenter.dc.id
Correct Answer: D
You decide to move a Terraform state le to Amazon S3 from another location. You write the code below into a le called backend.tf.
Which command will migrate your current state le to the new S3 remote backend?
A. terraform state
B. terraform init
C. terraform refresh
D. terraform push
Correct Answer: B
You want to tag multiple resources with a string that is a combination of a generated random_id and a variable.
How should you use the same value in all these resources without repeating the random_id and variable in each resource?
A. Local values
B. Data source
C. Modules
D. Outputs
Correct Answer: A
A. Interpolation
B. Reusability of code
C. Versioning
D. Automation
Correct Answer: A
Question #206 Topic 1
A. True
B. False
Correct Answer: B
While deploying a virtual machine, the rst launch user_data script fails due to race condition with another resource deployed during the same
Terraform run.
A. Run terraform taint against the virtual machine’s resource name, then terraform apply
Correct Answer: A
A. True
B. False
Correct Answer: A
Both Terraform Cloud and Terraform Enterprise support policy as code (Sentinel).
A. True
B. False
Correct Answer: A
Question #210 Topic 1
You want to de ne multiple data disks as nested blocks inside the resource block for a virtual machine.
What Terraform feature would help you de ne the blocks using the values in a variable?
A. Local values
B. Collection functions
C. Dynamic blocks
D. Count arguments
Correct Answer: C
Which of the following module source paths does not specify a remote module?
A. source = “./modules/consul”
B. source = “[email protected]:hashicorp/example.git”
C. source = “github.com/hashicorp/example”
D. source = “hashicorp/consul/aws”
Correct Answer: C
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. max(numcpus)
B. ceil(numcpus)
C. top(numcpus)
D. high[numcpus]
Correct Answer: A
A. True
B. False
Correct Answer: B
A. list
B. map
C. array
D. string
Correct Answer: C
B. A state le represents a source of truth for resources provisioned with a public cloud console
C. A state le represents the desired state expressed by the Terraform code les
Correct Answer: A
C. Plans and applies can be triggered via version control system integrations
Correct Answer: C
A. State is used to map real world resources to your con guration and keep track of metadata
C. State is used to enforce resource con gurations that relate to compliance policies
Correct Answer: B
A. API
B. Remote
C. Terraform Cloud
D. Local
E. HTTP
Correct Answer: D
Using the terraform state rm command against a resource will destroy it.
A. True
B. False
Correct Answer: A
Which method for sharing Terraform con gurations keeps them con dential within your organization, supports Terraform’s semantic version
constraints, and provides a browsable directory?
Correct Answer: B
You are writing a child Terraform module which provisions an AWS instance. You want to make use of the IP address returned in the root
con guration. You name the instance resource “main”.
Which of these is the correct way to de ne the output value using HCL2?
A.
B.
C.
D.
Correct Answer: C
How would you refer to the indexing instance from the below con guration?
A. aws_instance[“web”][“indexing”]
B. aws_instance.web.indexing
C. aws_instance-web[“indexing”]
D. aws_instance.web[“indexing”]
Correct Answer: D
A. Workspace
C. Audit logging
Correct Answer: D
A. After you run terraform apply for the rst time in a new Terraform project and before you run terraform plan
B. After you run terraform plan for the rst time in a new Terraform project and before you run terraform apply
C. After you start coding a new Terraform project and before you run terraform plan for the rst time
Correct Answer: D
Terraform con guration (including any module references) can contain only one Terraform provider type.
A. True
B. False
Correct Answer: A
You are making changes to existing Terraform code to add some new infrastructure.
A. After you run terraform plan so you can validate that your state le is consistent with your infrastructure
B. Before you run terraform plan so you can validate your code syntax
C. Before you run terraform apply so you can validate your infrastructure changes
D. After you run terraform apply so you can validate that your infrastructure is re ected in your code
Correct Answer: B
B. The order that resources appear in Terraform con guration indicates dependencies
Correct Answer: B
B. Compares the state le to your Terraform code and determines if any changes need to be made
C. Imports all of your existing cloud provider resources to your Terraform con guration le
D. Compares your Terraform code and local state le to the remote state le in a cloud provider and determines if any changes need to be
made
Correct Answer: D
What are some bene ts of using Sentinel with Terraform Cloud/Terraform Enterprise? (Choose three.)
B. You can restrict speci c con gurations on resources like "CIDR=0.0.0.0/0" not allowed
You want to share Terraform state with your team, store it securely, and provide state locking.
A. Using the remote Terraform backend with Terraform Cloud / Terraform Enterprise.
C. Using the s3 terraform backend. The dynamodb_ eld option is not needed.
D. Using an s3 terraform backend with an appropriate IAM policy and dynamodb_ eld option con gured.
A. Local path
B. GitHub Repository
Correct Answer: D
Correct Answer: C
You have decided to create a new Terraform workspace to deploy a development environment.
Correct Answer: A
Any user can publish modules to the public Terraform Module Registry.
A. True
B. False
Correct Answer: A