A Terraform output that sets the "sensitive" argument to true will not store that value in the state file.
You are tasked with making a change to an infrastructure stack running in a public cloud using HCP Terraform/Terraform Cloud. Which pattern follows IaC best practices?
Exhibit:
resource "azurerm_linux_web_app" "app" {
name = "example-app"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
service_plan_id = azurerm_service_plan.plan.id
identity {
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.app.id]
}
}
resource "azurerm_role_assignment" "kv_access" {
scope = azurerm_key_vault.kv.id
role_definition_name = "Key Vault Secrets User"
principal_id = azurerm_user_assigned_identity.app.principal_id
}
Two resource blocks are shown: azurerm_linux_web_app and azurerm_role_assignment. When provisioned, the web app will use the role assignment during creation, so the role assignment must be created first. How do you ensure the azurerm_role_assignment resource is created first?
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
You have created a main.tf Terraform configuration consisting of an application server, a database and a load balanced. You ran terraform apply and Terraform created all of the resources successfully.
Now you realize that you do not actually need the load balancer, so you run terraform destroy without any flags. What will happen?
As a member of an operations team that uses infrastructure as code (lac) practices, you are tasked with making a change to an infrastructure stack running in a public cloud. Which pattern would follow laC best practices for making a change?
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?
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
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?
Exhibit:
data "aws_ami" "web" {
most_recent = true
owners = ["self"]
tags = {
Name = "web-server"
}
}
A data source is shown in the exhibit. How do you reference the id attribute of this data source?
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
The -refresh-only parameter will update your state file when used with terraform plan.
Which of the following can you do with terraform plan? (Pick 2 correct responses)
When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
Which command(s) adds existing resources in a public cloud into Terraform state?
A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of that resource block?
Which of the following should you add in the required_providers block to define a provider version constraint?
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.
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?
When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
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?
You use a cloud provider account that is shared with other team members. You previously used Terraform to create a load balancer that listens on port 80. After 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 run terraform apply upon returning to your desk?
In a Terraform Cloud workpace linked to a version control repository speculative plan rum start automatically commit changes to version control.
Which of the following isnotan advantage of using Infrastructure as Code (IaC) operations?
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?
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?
You're writing a Terraform configuration that needs to read input from a local file called id_rsa.pub. Which built-in Terraform function can you use to import the file's contents as a string?
Which of the following ate advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.
You’ve enabled DEBUG-level logging for Terraform, and you’d like to send the log data to a file. Which action should you take?
When you use a remote backend that needs authentication, HashiCorp recommends that you:
You can define multiple backend blocks in your Terraform configuration to store your state in multiple locations.
Exhibit:
variable "sizes" {
type = list(string)
description = "Valid server sizes"
default = ["small", "medium", "large"]
}
A variable declaration is shown in the exhibit. Which is the correct way to get the value of medium from this variable?
A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
A developer accidentally launched a VM (virtual machine) outside of the Terraform workflow and ended up with two servers with the same name. They don't know which VM Terraform manages but do have a list of all active VM IDs.
Which of the following methods could you use to discover which instance Terraform manages?
How would you reference the volume IDs associated with the ebs_block_device blocks in this configuration?
terraform validate confirms that your infrastructure matches the Terraform state file.
One cloud block always maps to a single HCP Terraform/Terraform Cloud workspace.
Your team is collaborating on infrastructure using Terraform and wants to format code to follow Terraform language style conventions. How can you update your code to meet these requirements?
What kind of configuration block will manage an infrastructure object with settings specified within the block?
You ate making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate?
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
Terraform configuration (including any module references) can contain only one Terraform provider type.
You modified your Terraform configuration to fix a typo in the resource ID by renaming it from photoes to photos. What configuration will you add to update the resource ID in state without destroying the existing resource?
Original configuration:
resource "aws_s3_bucket" "photoes" {
bucket_prefix = "images"
}
Updated configuration:
resource "aws_s3_bucket" "photos" {
bucket_prefix = "images"
}
You modified your Terraform configuration and run Terraform plan to review the changes. Simultaneously, your teammate manually modified the infrastructure component you are working on. Since you already ran terraform plan locally, the execution plan for terraform apply will be the same.
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?
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 want to define multiple data disks as nested blocks inside the resource block for a virtual machine. What Terraform feature would help you define the blocks using the values in a variable?
What is the Terraform style convention for indenting a nesting level compared to the one above 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)
You can reference a resource created with for_each using a Splat ( *) expression.
You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.
Module version is required to reference a module on the Terraform Module Registry.
Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)
A Terraform backend determines how Terraform loads state and stores updates when you execute which command?