WorksheetsT1 # 1-55
Total questions: 55
Worksheet time: 55mins
The terraform.tfstate file always matches your currently built infrastructure.
True
False
One remote backend configuration always maps to a single remote workspace.
True
False
How is the Terraform remote backend different than other state backends such as S3, Consul, etc.?
It can execute Terraform runs on dedicated infrastructure on premises or in Terraform Cloud
It doesn't show the output of a terraform apply locally
It is only available to paying customers
All of the above
What is the workflow for deploying new infrastructure with Terraform?
terraform plan to import the current infrastructure to the state file, make code changes, and
terraform apply to update the infrastructure
Write a Terraform configuration, run terraform show to view proposed changes, and terraform
apply to create new infrastructure.
terraform plan to import the current infrastructure to the state file, make code changes, and
terraform apply to update the infrastructure
Write a Terraform configuration, run terraform init, run terraform plan to view planned
infrastructure
A provider configuration block is required in every Terraform configuration.
Example:
provider "provider_name" {
...
}
True
False
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?
terraform taint null_resource.run_script
terraform apply -target=null_resource.run_script
terraform validate null_resource.run_script
terraform plan -target=null_resource.run_script
Which provisioner invokes a process on the resource created by Terraform?
remote-exec
null-exec
local-exec
file
Which of the following is not true of Terraform providers?
Providers can be written by individuals
Providers can be maintained by a community of users
Some providers are maintained by HashiCorp
Major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers
None of the above
What command does Terraform require the first time you run it within a configuration directory?
terraform import
terraform init
terraform plan
terraform workspace
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?
Run terraform output ip_address to view the result
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
Run terraform state list to find the name of the resource, then terraform state show to find the
attributes including public IP address
Run terraform destroy then terraform apply and look for the IP address in stdout
Which of the following is not a key principle of infrastructure as code?
Versioned infrastructure
Golden images
Idempotence
Self-describing infrastructure
Terraform variables and outputs that set the "description" argument will store that description in the state file.
True
False
What is the provider for this fictitious resource?
resource "was_vpc" "main" {
name = "test"
}
VPC
main
aws
test
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
Run terraform refresh
It will happen automatically
Manually update the state fire
Run terraform import
What is not processed when running a terraform refresh?
State file
Configuration file
Credentials
Cloud provider
What information does the public Terraform Module Registry automatically expose about published modules?
Required input variables
Optional inputs variables and default values
Outputs
All of the above
None of the above
If a module uses a local variable, you can expose that value with a terraform output.
True
False
You should store secret data in the same version control repository as your Terraform configuration.
True
False
Which of the following is not a valid string function in Terraform?
split
join
slice
chomp
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.)
Provision new VMs using Terraform with the same VM names
Use the terraform import command for the existing VMs
Write Terraform configuration for the existing VMs
Run the terraform import-gcp command
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?
Implement a ticketing workflow that makes engineers submit a ticket before manually
provisioning and configuring a resource
Implement a checklist that engineers can follow when configuring compute instances
Replace the compute instance type with a larger version to reduce the number of required
deployments
Implement a provisioning pipeline that deploys infrastructure configurations committed to your
version control system following code reviews
terraform init initializes a sample main.tf file in the current directory.
true
false
Which two steps are required to provision new infrastructure in the Terraform workflow? (Choose two.)
Destroy
Apply
Import
Init
Validate
Why would you use the terraform taint command?
When you want to force Terraform to destroy a resource on the next apply
When you want to force Terraform to destroy and recreate a resource on the next apply
When you want Terraform to ignore a resource on the next apply
When you want Terraform to destroy all the infrastructure in your workspace
Terraform requires the Go runtime as a prerequisite for installation.
True
False
When should you use the force-unlock command?
You see a status message that you cannot acquire the lock
You have a high priority change
Automatic unlocking failed
Your apply failed due to a state lock
Terraform can import modules from a number of sources – which of the following is not a valid source?
FTP server
GitHub repository
Local path
Terraform Module Registry
Which of the following is available only in Terraform Enterprise or Cloud workspaces and not in Terraform CLI?
Secure variable storage
Support for multiple cloud providers
Dry runs with terraform plan
Using the workspace as a data source
terraform validate validates the syntax of Terraform files.
True
False
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.)
Run terraform plan -destroy.
This is not possible. You can only show resources that will be created.
Run terraform state rm *.
Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval
Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers?
servers = num_servers
servers = variable.num_servers
servers = var(num_servers)
servers = var.num_servers
A Terraform provisioner must be nested inside a resource configuration block.
True
False
Terraform can run on Windows or Linux, but it requires a Server version of the Windows operating system.
True
False
What does the default "local" Terraform backend store?
tfplan files
Terraform binary
Provider plugins
State file
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?
Run the terraform fmt command during the code linting phase of your CI/CD process
Designate one person in each team to review and format everyone's code
Manually apply two spaces indentation and align equal sign "=" characters in every Terraform file (*.tf)
Write a shell script to transform Terraform files using tools such as AWK, Python, and sed
What value does the Terraform Cloud/Terraform Enterprise private module registry provide over the public Terraform Module Registry?
The ability to share modules with public Terraform users and members of Terraform Enterprise
Organizations
The ability to tag modules by version or release
The ability to restrict modules to members of Terraform Cloud or Enterprise organizations
The ability to share modules publicly with any user of Terraform
Which task does terraform init not perform?
Sources all providers present in the configuration and ensures they are downloaded and available locally
Connects to the backend
Sources any modules and copies the configuration locally
Validates all required variables are present
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.)
{ for o in var.list : o => o.id }
var.list[*].id
[ var.list[*].id ]
[ for o in var.list : o.id ]
Which argument(s) is (are) required when declaring a Terraform variable?
type
default
description
All of the above
None of the above
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?
Modules stored on the public Terraform Module Registry do not support versioning
Append ?ref=v1.0.0 argument to the source path
Add version = "1.0.0" attribute to module block
Nothing – modules stored on the public Terraform Module Registry always default to version 1.0.0
What features does the hosted service Terraform Cloud provide? (Choose two.)
Automated infrastructure deployment visualization
Automatic backups
Remote state storage
A web-based user interface (UI)
Where does the Terraform local backend store its state?
Where does the Terraform local backend store its state?
In the terraform.tfvars file
In the terraform.tfstate file
In the user's .terraformrc file
Which option can not be used to keep secrets out of Terraform configuration files?
A Terraform provider
Environment variables
A -var flag
secure string
What is one disadvantage of using dynamic blocks in Terraform?
They cannot be used to loop through a list of values
Dynamic blocks can construct repeatable nested blocks
They make configuration harder to read and understand
Terraform will run more slowly
Only the user that generated a plan may apply it.
True
False
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?
aws_ami.ubuntu
data.aws_ami.ubuntu
data.aws_ami.ubuntu.id
aws_ami.ubuntu.id
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)
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?
The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and
select the newly-created VM.
The Terraform state file only contains the one new VM. Execute terraform destroy.
Delete the Terraform state file and execute Terraform apply.
Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state file.
What is the name assigned by Terraform to reference this resource?
dev
azurerm_resource_group
azurerm
test
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into syslog.
True
False
Where in your Terraform configuration do you specify a state backend?
The terraform block
The resource block
The provider block
The datasource block
In Terraform 0.13 and above, outside of the required_providers block, Terraform configurations always refer to providers by their local names.
True
False
What command should you run to display all workspaces for the current configuration?
terraform workspace
terraform workspace show
terraform workspace list
terraform show workspace
Terraform providers are always installed from the Internet.
True
False
Which of these is the best practice to protect sensitive values in state files?
Blockchain
Secure Sockets Layer (SSL)
Enhanced remote backends
Signed Terraform providers
