Test Preparation Flashcards

1
Q

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

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A. True
B. False

A

A. True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is the Terraform remote backend different than other state backends such as S3, Consul, etc.?

A. It can execute Terraform runs on dedicated infrastructure on premises or in Terraform Cloud
B. It doesn’t show the output of a terraform apply locally
C. It is only available to paying customers
D. All of the above

A

A. It can execute Terraform runs on dedicated infrastructure on premises or in Terraform Cloud

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the workflow for deploying new infrastructure with Terraform?

A. terraform plan to import the current infrastructure to the state file, make code changes, and terraform apply to update the infrastructure.
B. Write a Terraform configuration, 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 file, make code changes, and terraform apply to update the infrastructure.
D. Write a Terraform configuration, run terraform init, run terraform plan to view planned infrastructure changes, and terraform apply to create new infrastructure.

A

D. Write a Terraform configuration, run terraform init, run terraform plan to view planned infrastructure changes, and terraform apply to create new infrastructure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A provider configuration block is required in every Terraform configuration.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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 first?

A. terraform taint null_resource.run_script
B. terraform apply -target=null_resource.run_script
C. terraform validate null_resource.run_script
D. terraform plan -target=null_resource.run_script

A

A. terraform taint null_resource.run_script

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which provisioner invokes a process on the resource created by Terraform?

A. remote-exec
B. null-exec
C. local-exec
D. file

A

A. remote-exec

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following is not true of Terraform providers?

A. Providers can be written by individuals
B. Providers can be maintained by a community of users
C. Some providers are maintained by HashiCorp
D. Major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers
E. None of the above

A

E. None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What command does Terraform require the first time you run it within a configuration directory?

A. terraform import
B. terraform init
C. terraform plan
D. terraform workspace

A

B. terraform init

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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 find the IP address of the resource you deployed?

A. Run terraform output ip_address to view the result
B. In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
D. Run terraform destroy then terraform apply and look for the IP address in stdout

A

C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which of the following is not a key principle of infrastructure as code?

A. Versioned infrastructure
B. Golden images
C. Idempotence
D. Self-describing infrastructure

A

B. Golden images

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Terraform variables and outputs that set the “description” argument will store that description in the state file.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the provider for this fictitious resource?

resource "aws_vpc" "main" {
  name = "test"
}

A. vpc
B. main
C. aws
D. test

A

C. aws

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A. Run terraform refresh
B. It will happen automatically
C. Manually update the state file
D. Run terraform import

A

A. Run terraform refresh

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is not processed when running terraform refresh?

A. State file
B. Configuration file
C. Credentials
D. Cloud provider

A

B. Configuration file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What information does the public Terraform Module Registry automatically expose about published modules?

A. Required input variables
B. Optional inputs variables and default values
C. Outputs
D. All of the above
E. None of the above

A

D. All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

If a module uses a local values, you can expose that value with terraform output.

A. True
B. False

A

A. True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

You should store secret data in the same version control repository as your Terraform configuration.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which of the following is not a valid string function in Terraform?

A. split
B. join
C. slice
D. chomp

A

C. slice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

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

A. Provision new VMs using Terraform with the same VM names
B. Use the terraform import command for the existing VMs
C. Write Terraform configuration for the existing VMs
D. Run the terraform import-gcp command

A

B. Use the terraform import command for the existing VMs
C. Write Terraform configuration for the existing VMs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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 configuring each compute instance manually. This has led to inconsistent configuration between each compute instance. How would you solve this using infrastructure as code?

A. Implement a ticketing workflow that makes engineers submit a ticket before manually provisioning and configuring a resource
B. Implement a checklist that engineers can follow when configuring 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 configurations committed to your version control system following code reviews

A

D. Implement a provisioning pipeline that deploys infrastructure configurations committed to your version control system following code reviews

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

terraform init initializes a sample main.tf file in the current directory.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

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

A. Destroy
B. Apply
C. Import
D. Init
E. Validate

A

B. Apply
D. Init

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Why would you use the terraform taint command?

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
C. When you want Terraform to ignore a resource on the next apply
D. When you want Terraform to destroy all the infrastructure in your workspace

A

B. When you want to force Terraform to destroy and recreate a resource on the next apply

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Terraform requires the Go runtime as a prerequisite for installation.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

When should you use the force-unlock command?

A. You see a status message that you cannot acquire the lock
B. You have a high priority change
C. Automatic unlocking failed
D. You apply failed due to a state lock

A

C. Automatic unlocking failed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

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
D. Terraform Module Registry

A

A. FTP server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

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

A. Secure variable storage
B. Support for multiple cloud providers
C. Dry runs with terraform plan
D. Using the workspace as a data source

A

A. Secure variable storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

terraform validate validates the syntax of Terraform files.

A. True
B. False

A

A. True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

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

A. Run terraform plan -destroy.
B. This is not possible. You can only show resources that will be created.
C. Run terraform state rm \*.
D. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.

A

A. Run terraform plan -destroy.
D. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

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

A

D. servers = var.num_servers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

A Terraform provisioner must be nested inside a resource configuration block.

A. True
B. False

A

A. True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Terraform can run on Windows or Linux, but it requires a Server version of the Windows operating system.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What does the default local Terraform backend store?

A. tfplan files
B. Terraform binary
C. Provider plugins
D. State file

A

D. State file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

You have multiple team members collaborating on infrastructure as code (IaC) using Terraform, and want to apply formatting standards for readability.
How can you format Terraform HCL (HashiCorp Configuration Language) code according to standard Terraform style convention?

A. Run the terraform fmt command during the code linting phase of your CI/CD process
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 file (*.tf)
D. Write a shell script to transform Terraform files using tools such as AWK, Python, and sed

A

A. Run the terraform fmt command during the code linting phase of your CI/CD process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

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
B. The ability to tag modules by version or release
C. The ability to restrict modules to members of Terraform Cloud or Enterprise organizations
D. The ability to share modules publicly with any user of Terraform

A

C. The ability to restrict modules to members of Terraform Cloud or Enterprise organizations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Which task does terraform init not perform?

A. Sources all providers present in the configuration and ensures they are downloaded and available locally
B. Connects to the backend
C. Sources any modules and copies the configuration locally
D. Validates all required variables are present

A

D. Validates all required variables are present

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

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

A. { for o in var.list : o => o.id }
B. var.list[*].id
C. [ var.list[*].id ]
D. [ for o in var.list : o.id ]

A

B. var.list[*].id
D. [ for o in var.list : o.id ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

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

A. type
B. default
C. description
D. All of the above
E. None of the above

A

E. None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

When using a module block to reference a module stored on the public Terraform Module Registry such as:
~~~
module “consul” {
source = “hashicorp/consul/aws”
}
~~~
How do you specify version 1.0.0?

A. Modules stored on the public Terraform Module Registry do not support versioning
B. Append ?ref=v1.0.0 argument to the source path
C. Add version = "1.0.0" attribute to module block
D. Nothing, modules stored on the public Terraform Module Registry always default to version 1.0.0

A

C. Add version = "1.0.0" attribute to module block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

What features does the hosted service Terraform Cloud provide? (Choose two.)

A. Automated infrastructure deployment visualization
B. Automatic backups
C. Remote state storage
D. A web-based user interface (UI)

A

C. Remote state storage
D. A web-based user interface (UI)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Where does the Terraform local backend store its state?

A. In the /tmp directory
B. In the terraform file
C. In the terraform.tfstate file
D. In the user’s terraform.state file

A

C. In the terraform.tfstate file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

Which option can not be used to keep secrets out of Terraform configuration files?

A. A Terraform provider
B. Environment variables
C. A -var flag
D. secure string

A

D. secure string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What is one disadvantage of using dynamic blocks in Terraform?

A. They cannot be used to loop through a list of values
B. Dynamic blocks can construct repeatable nested blocks
C. They make configuration harder to read and understand
D. Terraform will run more slowly

A

C. They make configuration harder to read and understand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Only the user that generated a plan may apply it.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

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?

data "aws_ami "ubuntu" {
  ...
}

resource "aws_instance" "web" {
  ami = \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
	instance_type = "t2.micro"
	
	tags = {
	  name = "HelloWorld"
	}
}

A. aws_ami.ubuntu
B. data.aws_ami.ubuntu
C. data.aws_ami.ubuntu.id
D. aws_ami.ubuntu.id

A

C. data.aws_ami.ubuntu.id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

You need to specify a dependency manually. What resource meta-parameter can you use to make sure Terraform respects the dependency?

A

depends_on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

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?

A. The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM.
B. The Terraform state file only contains the one new VM. Execute terraform destroy.
C. Delete the Terraform state file and execute terraform apply.
D. Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state file.

A

B. The Terraform state file only contains the one new VM. Execute terraform destroy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

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

resource "azurerm_resource_group" "dev" {
  name = "test"
	location = "westus"
}

A. dev
B. azurerm_resource_group
C. azurerm
D. test

A

A. dev

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into syslog.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Where in your Terraform configuration do you specify a state backend?

A. The terraform block
B. The resource block
C. The provider block
D. The datasource block

A

A. The terraform block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

In Terraform 0.13 and above, outside of the required_providers block, Terraform configurations always refer to providers by their local names.

A. True
B. False

A

A. True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

What command should you run to display all workspaces for the current configuration?

A. terraform workspace
B. terraform workspace show
C. terraform workspace list
D. terraform show workspace

A

C. terraform workspace list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

Terraform providers are always installed from the Internet.

A. True
B. False

A

B. False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

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

A. Blockchain
B. Secure Sockets Layer (SSL)
C. Enhanced remote backends
D. Signed Terraform providers

A

C. Enhanced remote backends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

When does terraform apply reflect changes in the cloud environment?

A. Immediately
B. However long it takes the resource provider to fulfill the request
C. After updating the state file
D. Based on the value provided to the -refresh command line argument
E. None of the above

A

B. However long it takes the resource provider to fulfill the request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

How would you reference the “name” value of the second instance of this fictitious resource?

resource "aws_instance" "web" {
  count = 2
	name = "terraform-${count.index}"
}

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

A

B. aws_instance.web[1].name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

A Terraform provider is not responsible for:

A. Understanding API interactions with some service
B. Provisioning infrastructure in multiple clouds
C. Exposing resources and data sources based on an API
D. Managing actions to take based on resource differences

A

B. Provisioning infrastructure in multiple clouds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Terraform provisioners can be added to any resource block.

A. True
B. False

A

A. True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What is terraform refresh intended to detect?

A. Terraform configuration code changes
B. Empty state files
C. State file drift
D. Corrupt state files

A

C. State file drift

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

Which flag would you add to terraform plan to save the execution plan to a file?

A

-out=FILENAME

62
Q

What is the name of the default file where Terraform stores the state?

A

terraform.tfstate

63
Q

A Terraform local value can reference other Terraform local values.

A. True
B. False

A

A. True

64
Q

Which of the following is not a valid Terraform collection type?

A. list
B. map
C. tree
D. set

A

C. tree

65
Q

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

A

B. False

66
Q

All standard backend types support state storage, locking, and remote operations like plan, apply and destroy.

A. True
B. False

A

B. False

67
Q

How can terraform plan aid in the development process?

A. Validates your expectations against the execution plan without permanently modifying state
B. Initializes your working directory containing your Terraform configuration files
C. Formats your Terraform configuration files
D. Reconciles Terraform’s state against deployed resources and permanently modifies state using the current status of deployed resources

A

A. Validates your expectations against the execution plan without permanently modifying state

68
Q

You would like to reuse the same Terraform configuration for your development and production environments with a different state file for each. Which command would you use?

A. terraform import
B. terraform workspace
C. terraform state
D. terraform init

A

B. terraform workspace

69
Q

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

mainresouce "google_compute_instance" "main" {
  name = "test"
}

A. compute_instance
B. main
C. google
D. test

A

B. main

70
Q

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?

A. Pass variables to Terraform with a -var flag
B. Copy the sensitive variables into your Terraform code
C. Store the sensitive variables in a secure_vars.tf file
D. Store the sensitive variables as plain text in a source code repository

A

A. Pass variables to Terraform with a -var flag

71
Q

Your security team scanned some Terraform workspaces and found secrets stored in a plaintext in state files. How can you protect sensitive data stored in Terraform state files?

A. Delete the state file every time you run Terraform
B. Store the state in an encrypted backend
C. Edit your state file to scrub out the sensitive data
D. Always store your secrets in a secrets.tfvars file.

A

B. Store the state in an encrypted backend

72
Q

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

A

A. True

73
Q

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

A. Set the environment variable TF_LOG=TRACE
B. Set verbose logging for each provider in your Terraform configuration
C. Set the environment variable TF_VAR_log=TRACE
D. Set the environment variable TF_LOG_PATH

A

A. Set the environment variable TF_LOG=TRACE

74
Q

How is terraform import run?

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

A

D. By an explicit call

75
Q

You have a simple Terraform configuration 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?

A. Terraform will remove the VM from state file
B. Terraform will report an error
C. Terraform will not make any changes
D. Terraform will recreate the VM

A

D. Terraform will recreate the VM

76
Q

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

A. Defined in Environment variables
B. Inside the backend block within the Terraform configuration
C. Defined in a connection configuration outside of Terraform
D. None of above

A

A. Defined in Environment variables

77
Q

Your DevOps team is currently using the local backend for your Terraform configuration. You would like to move to a remote backend to begin storing the state file in a central location. Which of the following backends would not work?

A. Amazon S3
B. Artifactory
C. Git
D. Terraform Cloud

A

C. Git

78
Q

Which backend does the Terraform CLI use by default?

A. Terraform Cloud
B. Consul
C. Remote
D. Local

A

D. Local

79
Q

When you initialize Terraform, where does it cache modules from the public Terraform Module Registry?

A. On disk in the /tmp directory
B. In memory
C. On disk in the .terraform sub-directory
D. They are not cached

A

C. On disk in the .terraform sub-directory

80
Q

You write a new Terraform configuration 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 first
B. Terraform needs to install the necessary plugins first
C. The Terraform CLI needs you to log into Terraform cloud first
D. Terraform requires you to manually run terraform plan first

A

B. Terraform needs to install the necessary plugins first

81
Q

What feature stops multiple admins from changing the Terraform state at the same time?

A. Version control
B. Backend types
C. Provider constraints
D. State locking

A

D. State locking

82
Q

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?

A. terraform apply rm aws_instance.ubuntu[1]
B. terraform state rm aws_instance.ubuntu[1]
C. terraform plan rm aws_instance.ubuntu[1]
D. terraform delete aws_instance.ubuntu[1]

A

B. terraform state rm aws_instance.ubuntu[1]

83
Q

Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.

A. True
B. False

A

B. False

84
Q

A terraform apply can not ________ infrastructure.

A. change
B. destroy
C. provision
D. import

A

D. import

85
Q

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?

A. version >= 2.1
B. version ~> 2.1
C. version = "<= 2.1"
D. version = ">= 2.1"

A

D. version = ">= 2.1"

86
Q

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?

A. Run an apply and confirm the planned changes
B. Inspect your Terraform state because you want to change it
C. Reinitialize because your configuration has changed
D. Inspect all Terraform outputs to make sure they are correct

A

A. Run an apply and confirm the planned changes

87
Q

Terraform provisioners that require authentication can use the ________ block.

A. connection
B. credentials
C. secrets
D. ssh

A

A. connection

88
Q

terraform validate reports syntax check errors from which of the following scenarios?

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

A

B. There is missing value for a variable

89
Q

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

A. count
B. name
C. source
D. version

A

B. name

90
Q

What type of block is used to construct a collection of nested configuration blocks?

A. for_each
B. repeated
C. nesting
D. dynamic

A

D. dynamic

91
Q

Module variable assignments are inherited from the parent module and do not need to be explicitly set.

A. True
B. False

A

B. False

92
Q

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?

A. With four spaces
B. With a tab
C. With three spaces
D. With two spaces

A

D. With two spaces

93
Q

Which of the following is not an action performed by terraform init?

A. Create a sample main.tf file
B. Initialize a configured backend
C. Retrieve the source code for all referenced modules
D. Load required provider plugins

A

A. Create a sample main.tf file

94
Q

HashiCorp Configuration Language (HCL) supports user-defined functions.

A. True
B. False

A

B. False

95
Q

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

A

B. Commit a change to the VCS working directory and branch that the Terraform Cloud workspace is connected to

96
Q

Terraform and Terraform providers must use the same major version number in a single configuration.

A. True
B. False

A

B. False

97
Q

Which statement describes a goal of infrastructure as code?

A. An abstraction from vendor specific APIs
B. Write once, run anywhere
C. A pipeline process to test and deliver software
D. The programmatic configuration of resources

A

D. The programmatic configuration of resources

98
Q

When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)

A. When a change is made to the resources via the Azure Cloud Console, the changes are recorded in a new state file
B. When a change is made to the resources via the Azure Cloud Console, Terraform will update the state file to reflect them during the next plan or apply
C. When a change is made to the resources via the Azure Cloud Console, the current state file 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 file

A

B. When a change is made to the resources via the Azure Cloud Console, Terraform will update the state file to reflect them during the next plan or apply
C. When a change is made to the resources via the Azure Cloud Console, the current state file will not be updated

99
Q

You need to deploy resources into two different cloud regions in the same Terraform configuration. To do that, you declare multiple provider configurations as follows:

provider "aws" {
  region = "us-east-1"
}

provider "aws" {
  alias = "west"
	region = "us-west-2"
}

What meta-argument do you need to configure 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

A

C. provider = aws.west

100
Q

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

A. Add node_count = var.node_count
B. Declare the variable in a terraform.tfvars file
C. Declare a node_count input variable for child module
D. Nothing, child modules inherit variables of parent module

A

C. Declare a node_count input variable for child module

101
Q

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

A. True
B. False

A

B. False

102
Q

Which option cannot be used to keep secrets out of Terraform configuration files?

A. Environment Variables
B. Mark the variable as sensitive
C. A Terraform provider
D. A -var flag

A

B. Mark the variable as sensitive

103
Q

Which of the following arguments are required when declaring a Terraform output?

A. sensitive
B. description
C. default
D. value

A

D. value

104
Q

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?

A. With a Sentinel policy, which runs before every apply
B. By adding variables to each TFE workspace to ensure these settings are always enabled
C. With an S3 module with proper settings for buckets
D. Auditing cloud storage buckets with a vulnerability scanning too

A

A. With a Sentinel policy, which runs before every apply

105
Q

Most Terraform providers interact with ____________.

A. API
B. VCS Systems
C. Shell scripts
D. None of the above

A

A. API

106
Q

terraform validate validates that your infrastructure matches the Terraform state file.

A. True
B. False

A

B. False

107
Q

What does terraform import allow you to do?

A. Import a new Terraform module
B. Use a state file to import infrastructure to the cloud
C. Import provisioned infrastructure to your state file
D. Import an existing state file to a new Terraform workspace

A

C. Import provisioned infrastructure to your state file

108
Q

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

module "vpc" {
  source = "terraform-and-modules/vpc/aws"
  cidr = "10.0.0.0/16"
  name = "test-vpc"
}
A

module.vpc.vpc_id

109
Q

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

resource "aws_instance" "example" {
  ami = "ami-abc123"
  instance_type = "t2.micro"

  ebs_block_device {
    device_name = "sda2"
    volume_size = 16
  }

  ebs_block_device {
    device_name = "sda3"
    volume_size = 20
  }
}

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

A

D. aws_instance.example.ebs_block_device.*.volume_id

110
Q

What does state locking accomplish?

A. Copies the state file from memory to disk
B. Encrypts any credentials stored within the state file
C. Blocks Terraform commands from modifying the state file
D. Prevents accidental deletion of the state file

A

C. Blocks Terraform commands from modifying the state file

111
Q

You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?

A. Run terraform apply -upgrade
B. Run terraform init -upgrade
C. Run terraform refresh
D. Upgrade your version of Terraform

A

B. Run terraform init -upgrade

112
Q

A module can always refer to all variables declared in its parent module.

A. True
B. False

A

B. False

113
Q

When you use a remote backend that needs authentication, HashiCorp recommends that you:

A. Use partial configuration to load the authentication credentials outside of the Terraform code
B. Push your Terraform configuration to an encrypted git repository
C. Write the authentication credentials in the Terraform configuration files
D. Keep the Terraform configuration files in a secret store

A

A. Use partial configuration to load the authentication credentials outside of the Terraform code

114
Q

You have a simple Terraform configuration 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?

A. Terraform will terminate and recreate the VM
B. Terraform will create another duplicate VM
C. Terraform will apply the VM to the state file
D. Nothing

A

D. Nothing

115
Q

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

A. Build a completely brand new set of infrastructure
B. Tear down the entire workspace infrastructure and rebuild it
C. Rebuild only the instances that were deleted
D. Stop and generate an error message about the missing instances

A

C. Rebuild only the instances that were deleted

116
Q

You have created a main.tf 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?

A. Terraform will destroy the application server because it is listed first in the code
B. Terraform will prompt you to confirm that you want to destroy all the infrastructure
C. Terraform will destroy the main.tf file
D. Terraform will prompt you to pick which resource you want to destroy
E. Terraform will immediately destroy all the infrastructure

A

B. Terraform will prompt you to confirm that you want to destroy all the infrastructure

117
Q

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

A. provider
B. resource
C. local
D. data

A

D. data

118
Q

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?

A. terraform apply
B. terraform plan
C. terraform show
D. terraform init

A

D. terraform init

119
Q

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

A. True
B. False

A

B. False

120
Q

You have to initialize a Terraform backend before it can be configured.

A. True
B. False

A

B. False

121
Q

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

A. Cloud infrastructure
B. The .terraform directory
C. The execution plan
D. State file
E. Terraform code

A

A. Cloud infrastructure
D. State file

122
Q

A Terraform backend determines how Terraform loads state and stores updates when you execute ________.

A. apply
B. taint
C. destroy
D. All of the above
E. None of the above

A

E. None of the above

123
Q

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

A. Tracking provider dependencies
B. There is no such file
C. Preventing Terraform runs from occurring
D. Storing references to workspaces which are locked

A

D. Storing references to workspaces which are locked

124
Q

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?

A. Use the terraform state rm command to remove the VM from state file
B. Use the terraform taint command targeting the VMs then run terraform plan and terraform apply
C. Use the terraform apply command targeting the VM resources only
D. Delete the Terraform VM resources from your Terraform code then run terraform plan and terraform apply

A

B. Use the terraform taint command targeting the VMs then run terraform plan and terraform apply

125
Q

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

A. The module’s configuration page on the Terraform Module Registry
B. Terraform Module Registry does not support versioning modules
C. The release tags in the associated repo
D. The module’s Terraform code

A

C. The release tags in the associated repo

126
Q

Terraform plan updates your state file.

A. True
B. False

A

B. False

127
Q

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

A. terraform fmt -check
B. terraform fmt -write-false
C. terraform fmt list -recursive
D. terraform fmt -check -recursive

A

D. terraform fmt -check -recursive

128
Q

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-exec
B. local-exec
C. remote-exec
D. file

A

C. remote-exec

129
Q

You are using a networking module in your Terraform configuration with the name label my_network. In your main configuration you have the following code:

output: "net_id" {
  value = module.my_network.vnet_id
}

When you run terraform validate, you get the following error:

Error: Reference to undeclared output value

  on main.tf line 12, in output "net_id":
  12: value = module.my_network.vnet_id

What must you do to successfully retrieve this value from your networking module?

A. Define the attribute vnet_id as a variable in the networking module
B. Change the referenced value to module.my_network.outputs.vnet_id
C. Define the attribute vnet_id as an output in the networking module
D. Change the referenced value to my_network.outputs.vnet_id

A

D. Change the referenced value to my_network.outputs.vnet_id

130
Q

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?

A.
~~~
output “instance_ip_addr {
value = “${aws_instance.main.private_ip}”
}
~~~
B.
~~~
output “instance_ip_addr {
return aws_instance.main.private_ip
}
~~~

A

A.
~~~
output “instance_ip_addr {
value = “${aws_instance.main.private_ip}”
}
~~~

131
Q

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 fulfillment process is generated
B. A request must be submitted for infrastructure changes
C. As additional resources are required, more tickets are submitted
D. A catalog of approved resources can be accessed from drop down lists in a request form

A

B. A request must be submitted for infrastructure changes
C. As additional resources are required, more tickets are submitted

132
Q

Which of the following statements about Terraform modules is not true?

A. Modules must be publicly accessible
B. Modules can be called multiple times
C. Module is a container for one or more resources
D. Modules can call other modules

A

A. Modules must be publicly accessible

133
Q

Which Terraform collection type should you use to store key/value pairs?

A. tuple
B. set
C. map
D. list

A

C. map

134
Q

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

A. Run terraform plan -destroy
B. Run terraform show -destroy
C. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval
D. Run terraform show -destroy

A

A. Run terraform plan -destroy
C. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval

135
Q

When do you need to explicitly execute terraform refresh?

A. Before every terraform plan
B. Before every terraform apply
C. Before every terraform import
D. None of the above

A

D. None of the above

136
Q

All Terraform Cloud tiers support team management and governance.

A. True
B. False

A

B. False

137
Q

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

A. The ability to delete infrastructure
B. The ability to update existing infrastructure
C. The ability to reuse best practice configurations and settings
D. The ability to autoscale a group of servers

A

C. The ability to reuse best practice configurations and settings

138
Q

You have modified your Terraform configuration to fix a typo in the Terraform ID of a resource from aws_security_group.http to aws_security_group.http

Original Configuration:

resource "aws_security_group" "htp" {
  name = "http"
  ingress {
    from_port = "80"
    to_port = "80"
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
	}
}

Updated Configuration:
~~~
resource “aws_security_group” “http” {
name = “http”
ingress {
from_port = “80”
to_port = “80”
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
}
}
~~~
Which of the following commands would you run to update the ID in state without destroying the resource?

A. terraform mv aws_security_group.htp aws_security_group.http
B. terraform apply
C. terraform refresh

A

A. terraform mv aws_security_group.htp aws_security_group.http

139
Q

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?

A.
~~~
provider {
“aws” {
profile = var.aws_profile
region = var.aws_region
}
“datadog” {
api_key = var.datadog_api_key
app_key = var.datadog_app_key
}
}

B.

provider “aws” {
profile = var.aws_profile
region = var.aws_region
}
provider “datadog” {
api_key = var.datadog_api_key
app_key = var.datadog_app_key
}
~~~
C.
~~~
terraform {
provider “aws” {
profile = var.aws_profile
region = var.aws_region
}
provider “datadog” {
api_key = var.datadog_api_key
app_key = var.datadog_app_key
}
}
~~~

A

B.
~~~
provider “aws” {
profile = var.aws_profile
region = var.aws_region
}
provider “datadog” {
api_key = var.datadog_api_key
app_key = var.datadog_app_key
}
~~~

140
Q

Terraform variable names are saved in the state file.

A. True
B. False

A

B. False

141
Q

Terraform Cloud is available only as a paid offering from HashiCorp.

A. True
B. False

A

B. False

142
Q

Which of the following is not a way to trigger terraform destroy?

A. Using the destroy command with auto-approve
B. Running terraform destroy from the correct directory and then typing “yes” when prompted in the CLI
C. Passing –destroy at the end of a plan request
D. Delete the state file and run terraform apply

A

C. Passing –destroy at the end of a plan request
D. Delete the state file and run terraform apply

143
Q

Which of the following is not an advantage of using infrastructure as code operations?

A. Self-service infrastructure deployment
B. Troubleshoot via a Linux diff command
C. Public cloud console configuration workflows
D. Modify a count parameter to scale resources
E. API driven workflows

A

C. Public cloud console configuration workflows

144
Q

You’re writing a Terraform configuration that needs to read input from a local file called id_rsa.pub. Which built-in Terraform function can you use to import the file’s contents as a string?

A. fileset("id_rsa.pub")
B. filebase64("id_rsa.pub")
C. templatefile("id_rsa.pub")
D. file("id_rsa.pub")

A

D. file("id_rsa.pub")

145
Q

What does Terraform use providers for? (Choose three.)

A. Provision resources for on-premises infrastructure services
B. Simplify API interactions
C. Provision resources for public cloud infrastructure services
D. Enforce security and compliance policies
E. Group a collection of Terraform configuration files that map to a single state file

A

A. Provision resources for on-premises infrastructure services
B. Simplify API interactions
C. Provision resources for public cloud infrastructure services

146
Q

You can reference a resource created with for_each using a Splat (*) expression.

A. True
B. False

A

B. False

147
Q

How does Terraform determine dependencies between resources?

A. Terraform automatically builds a resource graph based on resources, provisioners, special meta-parameters, and the state file, if present.
B. Terraform requires all dependencies between resources to be specified using the depends_on parameter
C. Terraform requires resources in a configuration to be listed in the order they will be created to determine dependencies
D. Terraform requires resource dependencies to be defined as modules and sourced in order

A

A. Terraform automatically builds a resource graph based on resources, provisioners, special meta-parameters, and the state file, if present.

148
Q

Which parameters does terraform import require? (Choose two.)

A. Path
B. Provider
C. Resource ID
D. Resource address

A

C. Resource ID
D. Resource address

149
Q

Once a new Terraform backend is configured with a Terraform code block, which command(s) is (are) used to migrate the state file?

A. terraform apply
B. terraform push
C. terraform destroy, then terraform apply
D. terraform init

A

D. terraform init

150
Q

What does this code do?

terraform {
  required_providers {
    aws = "~> 3.0"
  }
}

A. Requires any version of the AWS provider >= 3.0 and < 4.0
B. Requires any version of the AWS provider >= 3.0
C. Requires any version of the AWS provider after the 3.0 major release, like 4.1
D. Requires any version of the AWS provider > 3.0

A

A. Requires any version of the AWS provider >= 3.0 and < 4.0