WorksheetsT7 # 333 - 382
Total questions: 48
Worksheet time: 48mins
When you use a remote backend that needs authentication. HashrCorp recommends that you:
Push your Tefraform configuration to an encrypted git repository
Write the authentication credentials in the Terraform configuration files
Use partial configuration to load the authentication credentials outside of the Terraform code
Keep the Terraform configuration files in a secret store
What is a key benefit of the Terraform state file?
A state file represents a source of truth for resources provisioned with a public cloud console
A state file represents a source of truth for resources provisioned with Terraform
A state file represents the desired state expressed by the Terraform code files
A state file can be used to schedule recurring infrastructure tasks
When using multiple configurations of the same Terraform provider, what meta-argument must be included in any non-default provider configurations?
name
alias
depends_on
id
In a Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.
True
False
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?
Terraform will not make any changes to the Load Balancer and will update the state file to reflect any changes made.
Terraform will change the port back to 80 in your code
Terraform will change the load balancer port to 80, and) then change it back to 443
Terraform will fail with in error because the state file is no longer accurate
Which parameters does terraform import require? Choose two correct answers.
Provider
Path
Resource address
Resource ID
If a DevOps team adopts AWS Cloud Formation as their standardized method for provisioning public cloud resources, which of the following scenarios poses a challenge for this team?
The team is asked to manage a new application stack built on AWS-natrve services
The organization decides to expand into Azure and wishes to deploy new infrastructure using their existing codebase
The team is asked to build a reusable code base that can deploy resources into any AWS region
The DevOps team is tasked with automating a manual provisioning process
As a member of the operations team, you need to run a script on a virtual machine created by Terraform. Which provisioned is best to use in your Terraform code?
local-exec
file
null-exec
remote-exec
The Terraform CLI will print output values from a child module after running terraform apply.
True
False
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?
TF_10G_PATM
TF_LOG
TF_10G_LEVEL
TF.LOG.FUE
What does terraform refresh modify?
Your cloud infrastructure
Your Terraform plan
Your state file
Your Terraform configuration
You have to initialize a Terraform backend before it can be configured.
True
False
Which task does teraform ini- not perform?
Sources any modules and copies the configuration locally
Validates all required variables are present
Connects to the backend
Sources all providers present in the configuration and ensures they are downloaded and available locally
Terraform plan updates your state file.
True
False
A terraform apply can not___________infrastructure.
import
provision
destroy
change
Terraform installs its providers during which phase?
man
init
refresh
All of the above
Terraform variable names are saved in the state file.
True
False
Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files without changing their contents.
True
False
Open source Terraform can only import publicly-accessible and open-source modules.
True
False
When does Sentinel enforce policy logic during a Terraform Enterprise run?
Before the plan phase
During the plan phase
Before the a apply phase
After the apply phase
terraform validate validate validates that your infrastructure matches the Terraform state file
True
False
You want to share Terraform state with your team, store it securely and provide state locking. How would you do this? Choose three correct answers.
Using the consul Terraform backend.
Using the remote Terraform backend with Terraform Cloud / Terraform Enterprise
Using the s3 terraform backend. The dynamodb_field option e not needed.
Using an s3 terraform backend with an appropriate IAM policy and dynamodb_field option configured.
All modules published on the official Terraform Module Registry have been verified by HashiCorp.
True
False
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
Which of the following commands would you run to update the ID in state without destroying the resource?
terraform refresh
terraform apply
terraform mv aws-security-group.htp aws-security-group.http
You have decided to create a new Terraform workspace to deploy a development environment. What is different about this workspace?
It uses a different branch of code
uses a different backend
It has its own state file
It pulls in a different terraform.tvars file
Which of the following can you do with terraform plan? Choose two correct answers.
View the execution plan and check if the changes match your expectations
Schedule Terraform to run at a planned time in the future
Execute a plan in a different workspace
Save a generated execution plan to apply later
What does this code do?
terraform {
required_providers {
was = "~> 3.0"
}
}
Requires any version of the AWS provider > = 3.0 and < 4.0
Requires any version of the AWS provider > = 3.0
Requires any version of the AWS provider after the 3.0 major release like 4.1
Requires any version of the AWS provider > 3.0
If a Terraform creation-time provisioner fails, what will occur by default?
The resource will not be affected, but the provisioner will need to be applied again
The resource will be destroyed
The resource will be marked as "tainted"
Nothing, provisioners will not show errors in the command line
Which Terraform collection type should you use to store key/value pairs?
set
tuple
list
map
What is the purpose of a Terraform workspace in either open source of enterprise?
Workspaces allow you to manage collections of infrastructure in state files.
A logical separation of business units
A method of grouping multiple infrastructure security policies
Provides limited access to a cloud environment
How would you be able to reference an attribute from the vsphere_datacenter data source for use with the argument within the vsprere_folder resource in the following configuration?
data "vsphare_datacenter" "dc" {}
resource "vsphare_folder" "parent" {
path = "Production"
type = "vm"
datacenter_id = ___________
}
vsphere_datacenter.dc.id
data.vsphere_datacenter.dc
data.dc,id
data.vsphere_datacenter.dc.id
You decide to move a Terraform state file to Amazon S3 from another location. You write the code below into a file called backend.tf
terraform {
backend "s3" {
bucket = "my-tf-bucket"
region = "us-east-1"
}
}
You immediately run terraform apply but don't see any changes. Your state file didn't move. Which command will migrate your current state file to the new S3 remote backend?
terraform push
terraform init
terraform refresh
terraform state
terraform init retrieves the source code tot all referenced modules
True
False
Terraform configuration (including any module references) can contain only one Terraform provider type.
True
False
Why should secrets not be hard coded into Terraform code? Choose two correct answers
All passwords should be rotated on a quarterly basis.
The Terraform code is copied to the target resources to be applied locally and could expose secrets if a target resource is compromised.
Terraform code is typically stored in version control, as well as copied to the systems from h it's run. Any of those may not have robust security mechanisms
It makes the code less reusable.
A Terraform output that sets the ''sensitive'' argument to true will not store that value in the state file.
True
False
terraform destroy is the only way to remove infrastructure.
True
False
Using the terraform state rm command against a resource will destroy it.
True
False
Which of the following is not a way to trigger terraform destroy ?
Passing ---destroy at the end of apian request
Running terraform destroy from the correct directory and then typing "yes" when prompted in the CLI
Using the destroy command with auto approve
Delete the state file and run terraform apply
terraform validate reports HCL syntax errors.
True
False
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.
(a)
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?
Use the Terraform taint command targeting the VMs then run Terraform plan and Terraform apply
Delete the Terraform VM resources from your Terraform code then run Terraform plan and terraform apply
Use the terraform apply command targeting the VM resources only
Use the terraform state rm command to remove the VM from state file
What kind of configuration block will create an infrastructure object with settings specified in the block?
state
provider
resource
data
Module version is required to reference a module on the Terraform Module Registry.
True
False
Which of the following does terraform apply change after you approve the execution plan? Choose two correct answers.
The execution plan
Terraform code
Cloud infrastructure
State file
The .terraform directory
Choose the answer that correctly completes the sentence: _______backends support state locking.
All
No
Only local
Some
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?
terreform providers- upgrade
terreform apply -upgrade
terreform refresh -upgrade
terreformn lnit -upgrade
What advantage does an operations team that uses infrastructure as code have?
The ability to delete infrastructure
The ability to reuse best practice configurations and settings
The ability to autoscale a group of servers
The ability to update existing infrastructure
