It is best practice to store secret data in the same version control repository as your Terraform configuration.
Your team often uses API calls to create and manage cloud infrastructure. In what ways does Terraform differ from conventional infrastructure management approaches?
Which of the following is not a way to trigger terraform destroy?
You are working on some new application features and you want to spin up a copy of your production deployment to perform some quick tests. In order to avoid having to configure a new state backend, what open source Terraform feature would allow you create multiple states but still be associated with your current code?
What is the name of the default file where Terraform stores the state?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.
Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?
Your Terraform configuration declares a variable. You want to enforce that its value meets your specific requirements, and you want to block the Terraform operation if it does not. What should you add to your configuration?
A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
You have a list of numbers that represents the number of free CPU cores on each virtual cluster:
numcpus = [ 18, 3, 7, 11, 2 ]
What Terraform function could you use to select the largest number from the list?
terraform init retrieves and caches the configuration for all remote modules.
Which of the following is not a benefit of adopting infrastructure as code?
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
A resource block is shown in the Exhibit space of this page. How would you reference the name value of the second instance of this resource?
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
Which of the following is true about terraform apply?(Pick 2 correct responses)
Your Terraform configuration manages a resource that requires maximum uptime. You need to update the resource, and when you run terraform plan, Terraform indicates that the update requires the resource to be destroyed and recreated.
Which lifecycle rule can you add to the resource to reduce downtime while still applying the update?
What is the provider for the resource shown in the Exhibit?
resource " aws_vpc " " main " {
name = " test "
}
Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Cloud automatically and proactively enforce this security control?
Which Terraform command checks that your configuration syntax is correct?
What information does the public Terraform Module Registry automatically expose about published modules?
You need to deploy resources into two different regions in the same Terraform configuration using the block shown in the exhibit below.
What do you need to add to the provider configuration to deploy the resource to the us-west-2 AWS region?
A data source is shown in the exhibit below.
How do you reference the id attribute of this data source?
}
}
How does Terraform manage most dependencies between resources?
Which task does terraform init not perform?
Which of these statements about Terraform Cloud workspaces is false?
What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?
The_________determines how Terraform creates, updates, or delete resources.
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?
Which of these statements about HCP Terraform/Terraform Cloud workspaces is false?
You provisioned virtual machines (VMs) on Google Cloud Platform using the gcloud command-line tool.
What must be done to manage these VMs using Terraform instead? Pick the two correct responses.
When you use a backend that requires authentication, it is best practice to:
You corrected a typo in a resource name, changing it from aws_s3_bucket.photoes to aws_s3_bucket.photos. You want to update the Terraform state so that the existing resource is recognized under the new name, without destroying and recreating it. Which configuration should you use?
Terraform installs its providers during which phase?
Which command add existing resources into Terraform state?
Only the user that generated a terraform plan may apply it.
You want to use API tokens and other secrets within your team ' s Terraform workspaces. Where does HashiCorp recommend you store these sensitive values?
(Pick 3 correct responses)
How do you specify a module’s version when publishing it to the public terraform Module Registry?
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 afterward without changing any Terraform code?
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 runfirst?
When you use a remote backend that needs authentication, HashiCorp recommends that you:
Which of these commands makes your code more human readable?
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
A Terraform local value can reference other Terraform local values.
Which of the following is not true of Terraform providers?
Which is a recommended way to share Terraform state across teams?
Which syntax check returns an error when you run terraform validate?
How does the Terraform cloud integration differ from other state backends such as S3, Consul,etc?
Which of the following should you add in the required_providers block to define a provider version constraint?
You want to create a string that combines a generated random_id and a variable and reuse that string several times in your configuration. What is the simplest correct way to implement this without repeating the random_id and variable?
terraform validate uses provider APIs to verify your infrastructure settings.
If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?
You are updating a child module with the resource block shown in the exhibit below. The public_ip attribute of the resource needs to be accessible to the parent module.
Exhibit:
resource " aws_instance " " example " {
ami = " ami-0a123456789abcdef "
instance_type = " t3.micro "
}
How do you meet this requirement?
What type of block is used to construct a collection of nested configuration blocks?
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
Which method for sharing Terraform modules fulfills the following criteria:
Keeps the module configurations confidential within your organization.
Supports Terraform ' s semantic version constraints.
Provides a browsable directory of your modules.
You have a Terraform configuration that defines a single virtual machine with no references to it, You have run terraform apply to create the resource, and then removed the resource definition from your Terraform configuration file.
What will happen you run terraform apply in the working directory again?
You’ve just finished refactoring part of your Terraform workspace’s configuration to use a module to manage some of your resources. When you plan your changes, you notice that Terraform will destroy and recreate the affected resources. Doing so could cause unintended downtime in the application your workspace manages. What supported approach should you take to complete the refactor without destroying and recreating your resources?
What is the workflow for deploying new infrastructure with Terraform?
Terraform providers are always installed from the Internet.
You have a saved execution plan containing desired changes for infrastructure managed by Terraform. After running the command terraform apply my.tfplan, you receive the error shown in the exhibit below.
Exhibit:
Error: Saved plan is stale
The given plan file can no longer be applied because the state was changed by another operation after the plan was created.
How can you apply the desired changes? (Choose TWO correct answers)
terraform init creates an example main.tf file in the current directory.
Exhibit:
Root module configuration:
output " vnet_id " {
value = module.my_network.vnet_id
}
Error:
Error: Reference to undeclared output value
on main.tf line 12, in output " vnet_id " :
12: value = module.my_network.vnet_id
You are using a networking module in your Terraform configuration with the name my_network. Your root module includes the configuration shown. When you run terraform validate, you get the error shown. Which option would successfully retrieve this value from your networking module?
Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.
If one of your modules uses a local value, you can expose that value to callers of the module by defining a Terraform output in the module’s configuration.
Your root module contains a variable namednum_servers. Which is the correct way to pass its value to a child module with an input namedservers?
What does terraform destroy do?
Terraformrequiresthe Go runtime as a prerequisite for installation.
You need to destroy all of the resources in your Terraform workspace, except for aws_instance.ubuntu[1], which you want to keep. How can you tell Terraform to stop managing that specific resource without destroying it?
When a check block’s assertion fails, Terraform blocks the current operation from executing.
A module block is shown in the Exhibit space of this page. When you use a module block to reference a module from the Terraform Registry such as the one in the example, how do you specify version 1.0.0 of the module?
Which command doesnotcause Terraform to refresh its state?
When you include a module block in your configuration that references a module from the Terraform Registry, the " version " attribute is required.
Which of the following does HCP Terraform perform during a health assessment for a workspace?
How can you configure a Terraform workspace to store its state remotely?
What kind of configuration block will create an infrastructure object with settings specified within the block?
Where does HashiCorp recommend you store API tokens and other secrets within your team’s Terraform workspaces?
Pick the three correct responses below.
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
Why would you use the -replace flag for terraform apply?
Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files, but will never change their contents.
Select the command that doesn’t cause Terraform to refresh its state.
If you update the version constraint in your Terraform configuration, Terraform will update your lock file the next time you run terraform Init.
A developer launched a VM outside of the Terraform workflow and ended up with two servers with the same name. They are unsure which VM is managed with Terraform, but they do have a list of all active VM IDs. Which method could you use to determine which instance Terraform manages?
terraform destroy is the only way to remove infrastructure.
What is the Terraform style convention for indenting a nesting level compared to the one above it?
Which method for sharing Terraform configurations fulfills the following criteria:
1. Keeps the configurations confidential within your organization
2. Support Terraform’s semantic version constrains
3. Provides a browsable directory
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
The exhibit below shows part of a Terraform configuration you have been asked to update. The name of the Azure Virtual Network should be set to the name of the resource group followed by a dash and the word vnet.
Exhibit:
data " azurerm_resource_group " " example " {
name = var.resource_group_name
}
resource " azurerm_virtual_network " " example " {
name = ______________________
}
Which expression fulfills this requirement?
Why is it considered important to treat your Terraform state file as sensitive?
You should run terraform fnt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions.
In a HCP Terraform/Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.
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.
Which command will migrate your current state file to the new S3 remote backend?
When you initialize Terraform, where does it cache modules from the public Terraform Registry?
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?
What functionality do providers offer in Terraform? (Pick the 3 correct responses below.)
Which of these is true about Terraform ' s plugin-based architecture?
What feature stops multiple users from operating on the Terraform state at the same time?
You add a new resource to an existing Terraform configuration, but do not update the version constraint in the configuration. The existing and new resources use the same provider. The working contains a .terraform.lock, hc1 file.
How will Terraform choose which version of the provider to use?
Before you can use a remote backend, you must first execute terra-form init.
Your configuration contains a module block that references a module from the Terraform Registry and sets the version argument to 1.0. You just published a new version of the module and updated your configuration to point to version 1.1.
Which command must be run to install the new version?
What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?
You want to use API tokens and other secrets within your team ' s Terraform workspaces. Where does HashiCorp recommend you store these sensitive values? (Pick 3)
When should you run terraform init?
Your team is using version 3.1.4 of a module from the public Terraform Registry, and they are worried about possible breaking changes in future versions of the module. Which version argument should you add to the module block to prevent newer versions from being used?
In Terraform HCL, an object type of object({name=string, age-number}) would match this value.
You are creating a reusable Terraform configuration and want to include an optional billing_dept tag so your Finance team can track team-specific spending on resources. Which of the following billing_dept variable declarations will achieve this?
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, then run terraform apply again without changing any Terraform code?