EMT Practice Test

1. Question Content...


Question List

Question1: What is the purpose of using the local-exec provisioner? (Select Two)

Question2: How do you specify a module's version when publishing it to the public Terraform Module Registry?

Question3: How would you reference the Volume IDs associated with the ebs_block_device blocks in this configuration?

Question4: When using multiple configurations of the same Terraform provider, what meta-argument must be included in
any non-default provider configurations?

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

Question6: 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.)

Question7: You need to migrate a workspace to use a remote backend. After updating your configuration, what command
do you run to perform the migration?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct
answer are accepted.

Question8: By default, a defined provisioner is a creation-time provisioner.

Question9: In the following code snippet, the block type is identified by which string?

Question10: Dawn has created the below child module. Without changing the module, can she override the instance_type
from t2.micro to t2.large form her code while calling this module?
1. resource "aws_instance" "myec2"
2. {
3. ami = "ami-082b5a644766e0e6f"
4. instance_type = "t2.micro
5. }

Question11: Terraform import command can import resources into modules as well directly into the root of your state.

Question12: Which of the following is available only in Terraform Enterprise or Cloud workspaces and not in Terraform
CLI?

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

Question14: When running the command terraform taint against a managed resource you want to force recreation upon,
Terraform will immediately destroy and recreate the resource.

Question15: A terraform apply can not___________infrastructure.

Question16: What is a downside to using the Vault provider to read secrets from Vault?

Question17: terraform state subcommands such as list are read-only commands, do read-only commands create state
backup files?

Question18: What Terraform command can be used to inspect the current state file?

Question19: Given the below resource configuration -
resource "aws_instance" "web" { # ... count = 4 }
What does the terraform resource address aws_instance.web refer to?

Question20: Terraform console provides an interactive command-line console for evaluating and experimenting with
expressions. You can use it to test interpolations before using them in configurations and to interact with any
values currently saved in state.
Which configuration consistency errors does terraform validate report?

Question21: You have declared a variable name my_var in terraform configuration without a value associated with it.
variable my_var {}
After running terraform plan it will show an error as variable is not defined.

Question22: Environment variables can be used to set variables. The environment variables must be in the format
"____"_<variablename>. Select the correct prefix string from the following list.

Question23: terraform refresh command will not modify infrastructure, but does modify the state file.

Question24: Your configuration file has been locked accidentally. What of the following command would you use to
unlock?

Question25: You have just developed a new Terraform configuration for two virtual machines with a cloud provider. You
would like to create the infrastructure for the first time.
Which Terraform command should you run first?

Question26: By default, where does Terraform store its state file?

Question27: When should Terraform configuration files be written when running terraform import on existing
infrastructure?

Question28: You are creating a Terraform configuration 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?


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

Question30: Which one of the following will run echo 0 and echo 1 on a newly created host?

Question31: A user has created a module called "my_test_module" and committed it to GitHub. Over time, several
commits have been made with updates to the module, each tagged in GitHub with an incremental version
number. Which of the following lines would be required in a module configuration block in terraform to select
tagged version v1.0.4?

Question32: How can terraform plan aid in the development process?

Question33: After creating a new workspace "PROD" you need to run the command terraform select PROD to switch to it.

Question34: 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?

Question35: Complete the following sentence:
The terraform state command can be used to ____

Question36: From the answers below, select the advantages of using Infrastructure as Code.

Question37: What is the name assigned by Terraform to reference this resource?

Question38: When using remote state, state is only ever held in memory when used by Terraform.

Question39: Which of the following challenges would Terraform be a candidate for solving? (Select THREE)

Question40: Which argument(s) is (are) required when declaring a Terraform variable?

Question41: You have created a main.tr Terraform configuration 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 flags What will happen?

Question42: Consider the following Terraform 0.12 configuration snippet:
1. variable "vpc_cidrs" {
2. type = map
3. default = {
4. us-east-1 = "10.0.0.0/16"
5. us-east-2 = "10.1.0.0/16"
6. us-west-1 = "10.2.0.0/16"
7. us-west-2 = "10.3.0.0/16"
8. }
9. }
10.
11. resource "aws_vpc" "shared" {
12. cidr_block = _____________
13. }
How would you define the cidr_block for us-east-1 in the aws_vpc resource using a variable?

Question43: Named workspaces are not a suitable isolation mechanism for strong separation between staging and
production?

Question44: Forcing the recreation of a resource is useful when you want a certain side effect of recreation that is not
visible in the attributes of a resource. What command will do this?

Question45: You have already set TF_LOG = DEBUG to enable debug log. Now you want to always write the log to the
directory you're currently running terraform from. what should you do to achieve this.

Question46: The terraform init command is always safe to run multiple times, to bring the working directory up to date
with changes in the configuration. Though subsequent runs may give errors, this command will never delete
your existing configuration or state.

Question47: Which of the following command can be used to view the specified version constraints for all providers used
in the current configuration.

Question48: While Terraform is generally written using the HashiCorp Configuration Language (HCL), what other syntax
can Terraform are expressed in?

Question49: A terraform apply can not _________ infrastructure.

Question50: From the code below, identify the implicit dependency:

Question51: Which of the below command will upgrade the provider version to the latest acceptable one?

Question52: In the example below, the depends_on argument creates what type of dependency?

Question53: terraform validate validates the syntax of Terraform files.

Question54: If you delete a remote backend from the configuration, will you need to rebuild your state files locally?

Question55: 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 configuration. To be safe, you would like to first 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.)

Question56: What does Terraform use .terraform.lock.hcl file for?

Question57: You have created two workspaces PROD and DEV. You have switched to DEV and provisioned DEV
infrastructure from this workspace. Where is your state file stored?

Question58: Select the answer below that completes the following statement: Terraform Cloud can be managed from the
CLI but requires __________?

Question59: Workspaces in Terraform provides similar functionality in the open-source, Terraform Cloud, and Enterprise
versions of Terraform.

Question60: In the below configuration, how would you reference the module output vpc_id?

Type your answer in the field provided. The text field is not case sensitive and all variations of the correct
answer are accepted.

Question61: What advantage does an operations team that uses infrastructure as code have?

Question62: What are some of the features of Terraform state? (select three)

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

Question64: 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)?

Question65: When should you use the force-unlock command?

Question66: Select two answers to complete the following sentence: Before a new provider can be used, it must be ______
and _______.

Question67: Examine the following Terraform configuration, which uses the data source for an AWS AMI.
What value should you enter for the ami argument in the AWS instance resource?

Question68: By default, provisioners that fail will also cause the Terraform apply itself to error. How can you change this
default behavior within a provisioner?

Question69: Which of the following actions are performed during a terraform init?

Question70: True or False: A list(...) contain a number of values of the same type while an object(...) can contain a number
of values of different types.

Question71: You wanted to destroy some of the dependent resources from real infrastructure. You choose to delete those
resources from your configuration file and run terraform plan and then apply. Which of the following way
your resources would be destroyed?

Question72: Refer to the below code where developer is outputting the value of the database password but has used
sensitive parameter to hide the output value in the CLI.
output "db_password" { value = aws_db_instance.db.password description = "The password for logging in to
the database." sensitive = true}
Since sensitive is set to true, the value associated with db password will not be present in state file as
plain-text?

Question73: 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 configuration?

Question74: 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 configured to make Terraform's logging more verbose?

Question75: A junior admin accidentally deleted some of your cloud instances. What does Terraform do when you run
terraform apply?

Question76: Which of the following is allowed as a Terraform variable name?

Question77: Which of the following locations can Terraform use as a private source for modules? (Choose two.)

Question78: 1. resource "aws_s3_bucket" "example" {
2. bucket = "my-test-s3-terraform-bucket"
3. ...} resource "aws_iam_role" "test_role" {
4. name = "test_role"
5. ...}
Due to the way that the application code is written, the s3 bucket must be created before the test role is
created, otherwise there will be a problem. How can you ensure that?

Question79: What does terraform refresh command do?

Question80: Please identify the offerings which are unique to Terraform Enterprise, and not available in either Terraform
OSS, or Terraform Cloud. Select four.

Question81: As a member of an operations team that uses infrastructure as code (laC) practices, you are tasked with making
a change to an infrastructure stack running in a public cloud. Which pattern would follow laC best practices
for making a change?

Question82: Which of the following is the safest way to inject sensitive values into a Terraform Cloud workspace?

Question83: What does terraform import allow you to do?

Question84: You have created a custom variable definition file my_vars.tfvars. How will you use it for provisioning
infrastructure?

Question85: Terraform can import modules from a number of sources - which of the following is not a valid source?

Question86: In order to reduce the time it takes to provision resources, Terraform uses parallelism. By default, how many
resources will Terraform provision concurrently?

Question87: Which of the below datatype is not supported by Terraform.

Question88: You need to specify a dependency manually. What resource meta-parameter can you use lo make sure
Terraform respects thee dependency?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct
answer are accepted.

Question89: Why might a user opt to include the following snippet in their configuration file?

Question90: Multiple configurations for the same provider can be used in a single configuration file.

Question91: How would you reference the "name" value of the second instance of this fictitious resource?

Question92: Running terraform fmt without any flags in a directory with Terraform configuration files will check the
formatting of those files without changing their contents.

Question93: Provider dependencies are created in several different ways. Select the valid provider dependencies from the
following list: (select three)

Question94: The following is a snippet from a Terraform configuration file:
Which, when validated, results in the following error:
Fill in the blank in the error message with the correct string from the list below.

Question95: Which backend does the Terraform CLI use by default?

Question96: 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
configuration 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?

Question97: When multiple engineers start deploying infrastructure using the same state file, what is a feature of remote
state storage that is critical to ensure the state doesn't become corrupt?

Question98: Multiple provider instances blocks for AWS can be part of a single configuration file?

Question99: Why should secrets not be hard coded into Terraform code? Choose two correct answers

Question100: Terraform variable names are saved in the state file.

Question101: Module version is required to reference a module on the Terraform Module Registry.

Question102: Suppose terraformcode is taking up some values which are not defined inside the code files. In which of the
following options issue might have occurred?

Question103: You need to constrain the GitHub provider to version 2.1 or greater.
Which of the following should you put into the Terraform 0.12 configuration's provider block?

Question104: When using a module block to reference a module stored on the public Terraform Module Registry such as:

How do you specify version 1.0.0?

Question105: To check if all code in a Terraform configuration with multiple modules is properly formatted without making
changes, what command should be run?

Question106: 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 configuration. You name the instance resource "main".
Which of these is the correct way to define the output value using HCL2?

Question107: Which two steps are required to provision new infrastructure in the Terraform workflow? (Choose two.)

Question108: Which one of the following command will rewrite Terraform configuration files to a canonical format and
style.

Question109: While using generic git repository as a module source, which of the below options allows terraform to select a
specific version or tag instead of selecting the HEAD.

Question110: You want terraform plan and terraform apply to be executed in Terraform Cloud's run environment but the
output is to be streamed locally. Which one of the below you will choose?

Question111: Your developers are facing a lot of problem while writing complex expressions involving difficult
interpolations . They have to run the terraform plan every time and check whether there are errors , and also
check terraform apply to print the value as a temporary output for debugging purposes. What should be done
to avoid this?

Question112: You are using a terraform operation that writes state. Unfortunately automatic state unlocking has failed for
that operation. Which of the below commands can be used to remove the already acquired lock on the state?

Question113: What is the name assigned by Terraform to reference this resource?

Question114: What is the provider for this fictitious resource?

Question115: John wants to use two different regions to deploy two different EC2 instances. He has specified two provider
blocks in his providers.tf file.
provider "aws" { region = "us-east-1" }
provider "aws" { region = "us-west-2" }
When he run terraform plan he encountered an error. How to fix this?

Question116: You have created a custom variable definition file testing.tfvars. How will you use it for provisioning
infrastructure?

Question117: Which argument(s) are required when declaring a Terraform variable?

Question118: True or False. The terraform refresh command is used to reconcile the state Terraform knows about (via its
state file) with the real-world infrastructure. If drift is detected between the real-world infrastructure and the
last known-state, it will modify the infrastructure to correct the drift.

Question119: Terraform will sync all resources in state by default for every plan and apply, hence for larger infrastructures
this can slow down terraform plan and terraform apply commands?

Question120: A user creates three workspaces from the command line - prod, dev, and test. Which of the following
commands will the user run to switch to the dev workspace?

Question121: Which of the following best describes a Terraform provider?

Question122: Which command lets you experiment with Terraform's built-in functions?

Question123: Using the terraform state rm command against a resource will destroy it.

Question124: terraform destroy is the only way to remove infrastructure.

Question125: A Terraform provider is not responsible for:

Question126: What does terraform destroy do?

Question127: John is writing a module and within the module, there are multiple places where he has to use the same
conditional expression but he wants to avoid repeating the same values or expressions multiple times in a
configuration,. What is a better approach to dealing with this?

Question128: You have provisioned some aws resources in your test environment through Terraform for a POC work. After
the POC, now you want to destroy the resources but before destroying them you want to check what resources
will be getting destroyed through terraform. what are the options of doing that? (Select TWO)

Question129: True or False: Workspaces provide identical functionality in the open-source, Terraform Cloud, and Enterprise
versions of Terraform.

Question130: You have a Terraform configuration that defines a single virtual machine with no references to it. You have
run terraform apply to create the resource, and then removed the resource definition from your Terraform
configuration file.
What will happen when you run terraform apply in the working directory again?

Question131: Which of the below options is a valid interpolation syntax for retrieving a data source?

Question132: Your company has a lot of workloads in AWS , and Azure that were respectively created using
CloudFormation , and AzureRM Templates. However , now your CIO has decided to use Terraform for all
new projects , and has asked you to check how to integrate the existing environment with terraform code.
What should be your next plan of action?

Question133: Which of these options is the most secure place to store secrets foe connecting to a Terraform remote
backend?

Question134: Which of the following is true about terraform apply? (Choose two.)

Question135: What Terraform feature is shown in the example below?

Question136: resource "aws_s3_bucket" "example" { bucket = "my-test-s3-terraform-bucket" ...} resource "aws_iam_role"
"test_role" { name = "test_role" ...}
Due to the way that the application code is written , the s3 bucket must be created before the test role is
created , otherwise there will be a problem. How can you ensure that?

Question137: 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?

Question138: Which of the following allows Terraform users to apply policy as code to enforce standardized configurations
for resources being deployed via infrastructure as code?

Question139: Which of these is the best practice to protect sensitive values in state files?

Question140: Your team has started using terraform OSS in a big way , and now wants to deploy multi region deployments
(DR) in aws using the same terraform files . You want to deploy the same infra (VPC,EC2 ...) in both
us-east-1 ,and us-west-2 using the same script , and then peer the VPCs across both the regions to enable DR
traffic. But , when you run your script , all resources are getting created in only the default provider region.
What should you do? Your provider setting is as below -
# The default provider configuration provider "aws" { region = "us-east-1" }

Question141: Resources in terraform can have same identifiers(Resource type + Block name).

Question142: Terraform Enterprise (also referred to as pTFE) requires what type of backend database for a clustered
deployment?

Question143: 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?

Question144: Which of the following can you do with terraform plan? Choose two correct answers.

Question145: Terraform plan updates your state file.

Question146: You want to know from which paths Terraform is loading providers referenced in your Terraform
configuration (files). You need to enable debug messages to find this out.
Which of the following would achieve this?

Question147: How is terraform import run?

Question148: Why would you use the terraform taint command?

Question149: When Terraform needs to be installed in a location where it does not have internet access to download the
installer and upgrades, the installation is generally known as to be __________.

Question150: If you enable TF_LOG = DEBUG, the log will be stored in syslog.log file in the currect directory.

Question151: Terraform is currently being used by your organisation to create resources on AWS for the development of a
web application. One of your coworkers wants to change the instance type to "t2.large" while keeping the
default set values.
What adjustments does the teammate make in order to meet his goal?

Question152: Which of the following is not valid source path for specifying a module?

Question153: Any user can publish modules to the public Terraform Module Registry.

Question154: You want to use different AMI images for different regions and for the purpose you have defined following
code block.
1.variable "images"
2.{
3. type = "map"
4.
5. default = {
6. us-east-1 = "image-1234"
7. us-west-2 = "image-4567"
8. us-west-1 = "image-4589"
9. }
10.}
What of the following approaches needs to be followed in order to select image-4589?

Question155: Where does the Terraform local backend store its state?

Question156: Which of the following best describes the default local backend?

Question157: Terraform has detailed logs which can be enabled by setting the _________ environmental variable.

Question158: What allows you to conveniently switch between multiple instances of a single configuration within its single
backend?

Question159: colleagues is new toTerraform and wants to add a new workspace named new-hire. What command he should
execute from the following?

Question160: Taint the resource "aws_instance" "baz" resource that lives in module bar which lives in module foo.

Question161: The terraform.tfstate file always matches your currently built infrastructure.

Question162: Your team uses terraform OSS . You have created a number of resuable modules for important , independent
network components that you want to share with your team to enhance consistency . What is the correct
option/way to do that?