Font size
WorksheetsT2 # 56-110
Total questions: 55
Worksheet time: 55mins
When does terraform apply reflect changes in the cloud environment?
Immediately
However long it takes the resource provider to fulfill the request
After updating the state file
Based on the value provided to the -refresh command line argument
None of the above
How would you reference the "name" value of the second instance of this fictitious resource?
element(aws_instance.web, 2)
aws_instance.web[1].name
aws_instance.web[1]
aws_instance.web[2].name
aws_instance.web.*.name
A Terraform provider is not responsible for:
Understanding API interactions with some service
Provisioning infrastructure in multiple clouds
Exposing resources and data sources based on an API
Managing actions to take based on resource differences
Terraform provisioners can be added to any resource block.
True
False
What is terraform refresh intended to detect?
Terraform configuration code changes
Empty state files
State file drift
Corrupt state files
Which flag would you add to terraform plan to save the execution plan to a file?
(a)
What is the name of the default file where Terraform stores the state?
(a)
A Terraform local value can reference other Terraform local values.
True
False
Which of the following is not a valid Terraform collection type?
list
map
tree
set
When running the command terraform taint against a managed resource you want to force recreation upon, Terraform will immediately destroy and recreate the resource.
True
False
All standard backend types support state storage, locking, and remote operations like plan. apply and destroy.
True
False
How can terraform plan aid in the development process?
Validates your expectations against the execution plan without permanently modifying state
Initializes your working directory containing your Terraform configuration files
Formats your Terraform configuration files
Reconciles Terraform’s state against deployed resources and permanently modifies state using the current status of deployed resources
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?
terraform import
terraform workspace
terraform state
terraform init
What is the name assigned by Terraform to reference this resource?
compute_instance
main
test
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?
Pass variables to Terraform with a –var flag
Copy the sensitive variables into your Terraform code
Store the sensitive variables in a secure_vars.tf file
Store the sensitive variables as plain text in a source code repository
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?
Delete the state file every time you run Terraform
Store the state in an encrypted backend
Edit your state file to scrub out the sensitive data
Always store your secrets in a secrets.tfvars file
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.
True
False
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?
Set the environment variable TF_LOG=TRACE
Set verbose logging for each provider in your Terraform configuration
Set the environment variable TF_VAR_log=TRACE
Set the environment variable TF_LOG_PATH
How is terraform import run?
As a part of terraform init
As a part of terraform plan
As a part of terraform refresh
By an explicit call
All of the above
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?
Terraform will remove the VM from state file
Terraform will report an error
Terraform will not make any changes
Terraform will recreate the VM
Which of these options is the most secure place to store secrets for connecting to a Terraform remote backend?
Defined in Environment variables
Inside the backend block within the Terraform configuration
Defined in a connection configuration outside of Terraform
None of above
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?
Amazon S3
Artifactory
Git
Terraform Cloud
Which backend does the Terraform CLI use by default?
Terraform Cloud
Consul
Remote
Local
When you initialize Terraform, where does it cache modules from the public Terraform Module Registry?
On disk in the /tmp directory
In memory
On disk in the .terraform sub-directory
They are not cached
You write a new Terraform configuration and immediately run terraform apply in the CLI using the local backend. Why will the apply fail?
Terraform needs you to format your code according to best practices first
Terraform needs to install the necessary plugins first
The Terraform CLI needs you to log into Terraform cloud first
Terraform requires you to manually run terraform plan first
What features stops multiple admins from changing the Terraform state at the same time?
Version control
Backend types
Provider constraints
State locking
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?
terraform apply rm aws_instance.ubuntu[1]
terraform state rm aws_instance.ubuntu[1]
terraform plan rm aws_instance.ubuntu[1]
terraform delete aws_instance.ubuntu[1]
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.
True
False
A terraform apply can not _________ infrastructure.
change
destroy
provision
import
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?
version >= 2.1
version ~> 2.1
version = “<= 2.1”
version = “>= 2.1”
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?
Run an apply and confirm the planned changes
Inspect your Terraform state because you want to change it
Reinitialize because your configuration has changed
Inspect all Terraform outputs to make sure they are correct
Terraform provisioners that require authentication can use the ______ block.
connection
credentials
secrets
ssh
Terraform validate reports syntax check errors from which of the following scenarios?
Code contains tabs indentation instead of spaces
There is missing value for a variable
The state files does not match the current infrastructure
None of the above
Which of the following is allowed as a Terraform variable name?
count
name
source
version
What type of block is used to construct a collection of nested configuration blocks?
for_each
repeated
nesting
dynamic
Module variable assignments are inherited from the parent module and do not need to be explicitly set.
True
False
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?
With four spaces
With a tab
With three spaces
With two spaces
Which of the following is not an action performed by terraform init?
Create a sample main.tf file
Initialize a configured backend
Retrieve the source code for all referenced modules
Load required provider plugins
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
Only Terraform Cloud organization owners can set workspace variables on VCS connected workspaces
Commit a change to the VCS working directory and branch that the Terraform Cloud workspace is connected to
Only members of a VCS organization can open a pull request against repositories that are connected to Terraform Cloud workspaces
Only Terraform Cloud organization owners can approve plans in VCS connected workspaces
Terraform and Terraform providers must use the same major version number in a single configuration.
True
False
Which statement describes a goal of infrastructure as code?
An abstraction from vendor specific APIs
Write once, run anywhere
A pipeline process to test and deliver software
The programmatic configuration of resources
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
When a change is made to the resources via the Azure Cloud Console, the changes are recorded in a new state file
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
When a change is made to the resources via the Azure Cloud Console, the current state file will not be updated
When a change is made to the resources via the Azure Cloud Console, the changes are recorded in the current state file
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:
What meta-argument do you need to configure in a resource block to deploy the resource to the “us- west-2” AWS region?
alias = west
provider = west
provider = aws.west
alias = aws.west
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?
Add node_count = var.node_count
Declare the variable in a terraform.tfvars file
Declare a node_count input variable for child module
Nothing, child modules inherit variables of parent module
If a module declares a variable with a default, that variable must also be defined within the module.
True
False
Terraform init can indeed be run only a few times, because, every time terraform init will initialize the project , and download all plugins from the internet repository , regardless of whether they were present or not , and this increases the waiting time
True
False
The Terraform language does not support user-defined functions, and so only the functions built in to the language are available for use
True
False
Which of the below configuration file formats are supported by Terraform? (Select TWO)
Node
JSON
Go
YAML
HCL
Please identify the offerings which are unique to Terraform Enterprise, and not available in either Terraform OSS, or Terraform Cloud. Select four.
Audit Logs
Private Network Connectivity
VCS Integration
Sentinel
Clustering
HashiCorp Configuration Language (HCL) supports user-defined functions.
True
False
terraform refresh command will not modify infrastructure, but does modify the state file.
True
False
Which of the following clouds does not have a provider maintained HashiCorp?
IBM Cloud
DigitalOcean
OpenStack
AWS
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.
True
False
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.
TF_CLI_ARGS
TF_VAR
TF_VAR_
TF_VAR_ENV
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.
True
False
