wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

T1 # 1-55

Total questions: 55

Worksheet time: 55mins

Name
Class
Date
1.

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

a)

True

b)

False

2.

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

a)

True

b)

False

3.

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

4.

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 plan 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

5.

A provider configuration block is required in every Terraform configuration.

Example:

provider "provider_name" {

...

}

a)

True

b)

False

6.

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

7.

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

a)

remote-exec

b)

null-exec

c)

local-exec

d)

file

8.

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

9.

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

10.

You have deployed a new webapp with a public IP address on a clod 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

11.

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

12.

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

a)

True

b)

False

13.

What is the provider for this fictitious resource?

resource "was_vpc" "main" {

name = "test"

}

a)

VPC

b)

main

c)

aws

d)

test

14.

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 fire

d)

Run terraform import

15.

What is not processed when running a terraform refresh?

a)

State file

b)

Configuration file

c)

Credentials

d)

Cloud provider

16.

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

17.

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

a)

True

b)

False

18.

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

a)

True

b)

False

19.

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

a)

split

b)

join

c)

slice

d)

chomp

20.

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

21.

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

22.

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

a)

true

b)

false

23.

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

24.

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

25.

Terraform requires the Go runtime as a prerequisite for installation.

a)

True

b)

False

26.

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)

Your apply failed due to a state lock

27.

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

28.

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

29.

terraform validate validates the syntax of Terraform files.

a)

True

b)

False

30.

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

31.

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

32.

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

a)

True

b)

False

33.

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

a)

True

b)

False

34.

What does the default "local" Terraform backend store?

a)

tfplan files

b)

Terraform binary

c)

Provider plugins

d)

State file

35.

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

36.

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

37.

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

38.

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 ]

39.

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

40.

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

41.

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)

42.

Where does the Terraform local backend store its state?

a)

Where does the Terraform local backend store its state?

b)

In the terraform.tfvars file

c)

In the terraform.tfstate file

d)

In the user's .terraformrc file

43.

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

44.

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

45.

Only the user that generated a plan may apply it.

a)

True

b)

False

46.

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?

a)

aws_ami.ubuntu

b)

data.aws_ami.ubuntu

c)

data.aws_ami.ubuntu.id

d)

aws_ami.ubuntu.id

47.

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 field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

(a)  

48.

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.

49.

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

a)

dev

b)

azurerm_resource_group

c)

azurerm

d)

test

50.

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

a)

True

b)

False

51.

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

52.

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

53.

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

54.

Terraform providers are always installed from the Internet.

a)

True

b)

False

55.

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