Spring Sale Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: mxmas70

Home > HashiCorp > Terraform Associate > Terraform-Associate-004

Terraform-Associate-004 HashiCorp Certified: Terraform Associate (004) (HCTA0-004) Question and Answers

Question # 4

You add a new provider to your configuration and immediately run terraform apply in the CD using the local backend. Why does the apply fail?

A.

The Terraform CD needs you to log into Terraform Cloud first

B.

Terraform requires you to manually run terraform plan first

C.

Terraform needs to install the necessary plugins first

D.

Terraform needs you to format your code according to best practices first

Full Access
Question # 5

Module variable assignments are inherited from the parent module and you do not need to explicitly set them.

A.

True

B.

False

Full Access
Question # 6

Which command(s) adds existing resources in a public cloud into Terraform state?

A.

terraform init

B.

terraform plan

C.

terraform refresh

D.

terraform import

E.

All of these

Full Access
Question # 7

What is the workflow for deploying new infrastructure with Terraform?

A.

Write Terraform configuration, run terraform init to initialize the working directory orworkspace, and run terraform apply

B.

Write Terraform configuration, run terraform show to view proposed changes, and terraform apply to create new infrastructure

C.

Write Terraform configuration, run terraform apply to create infrastructure, use terraform validate to confirm Terraform deployed resources correctly

D.

Write Terraform configuration, run terraform plan to initialize the working directory or workspace, and terraform apply to create the infrastructure

Full Access
Question # 8

What does Terraform not reference when running a terraform apply -refresh-only ?

A.

State file

B.

Credentials

C.

Cloud provider

D.

Terraform resource definitions in configuration files

Full Access
Question # 9

Which command doesnotcause Terraform to refresh its state?

A.

terraform state list

B.

terraform plan

C.

terraform apply

D.

terraform destroy

Full Access
Question # 10

Before you can use a remote backend, you must first execute terra-form init.

A.

True

B.

False

Full Access
Question # 11

You can access state stored with the local backend by using terraform_remote_state data source.

A.

True

B.

False

Full Access
Question # 12

If a module declares a variable without a default value, you must pass the value of the variable within the module block when you call the module in your configuration.

A.

True

B.

False

Full Access
Question # 13

You can develop a custom provider to manage its resources using Terraform.

A.

True

B.

False

Full Access
Question # 14

When should you use the force-unlock command?

A.

You have a high priority change

B.

Automatic unlocking failed

C.

apply failed due to a state lock

D.

You see a status message that you cannot acquire the lock

Full Access
Question # 15

What information does the public Terraform Module Registry automatically expose about published modules?

A.

Required input variables

B.

Optional inputs variables and default values

C.

Outputs

D.

All of the above

E.

None of the above

Full Access
Question # 16

You should run terraform fnt to rewrite all Terraform configurations within the current working directory to conform to Terraform-style conventions.

A.

True

B.

False

Full Access
Question # 17

Which task does terraform init not perform?

A.

Discovers all providers used in the configuration and downloads them.

B.

Validates that values are set for all required input variables.

C.

Connects to the configured backend.

D.

Discovers any remote modules and downloads them.

Full Access
Question # 18

The terraform output command shows outputs from child modules.

A.

True

B.

False

Full Access
Question # 19

Which of the following can you do with terraform plan? (Pick 2 correct responses)

A.

Schedule Terraform to run at a planned time in the future.

B.

View the execution plan and check if the changes match your expectations.

C.

Save a generated execution plan to apply later.

D.

Execute a plan in a different workspace.

Full Access
Question # 20

How can a ticket-based system slow down infrastructure provisioning and limit the ability to scale? Choose two correct answers.

A.

End-users have to request infrastructure changes

B.

Ticket based systems generate a full audit trail of the request and fulfillment process

C.

Users can access catalog of approved resources from drop down list in a request form

D.

The more resources your organization needs, the more tickets your infrastructure team has to process

Full Access
Question # 21

Which of the following is not a valid Terraform variable type?

A.

list

B.

array

C.

nap

D.

string

Full Access
Question # 22

Which is a benefit of the Terraform state file?

A.

A state file can schedule recurring infrastructure tasks.

B.

A state file is the desired state expressed by the Terraform code files.

C.

A state file is a source of truth for resources provisioned with Terraform.

D.

A state file is a source of truth for resources provisioned with a public cloud console.

Full Access
Question # 23

You have used Terraform lo create an ephemeral development environment in the (loud 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 Terraform will delete.

Which command should you use to show all of the resources that mil be deleted? Choose two correct answers.

A.

Run terraform state rm ‘

B.

Run terraform show :destroy

C.

Run terraform destroy and it will first output all the resource that will be deleted before prompting for approval

D.

Run terraform plan .destory

Full Access
Question # 24

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?

A.

Copy the sensitive variables into your Terraform code

B.

Store the sensitive variables in a secure_varS.tf file

C.

Store the sensitive variables as plain text in a source code repository

D.

Pass variables to Terraform with a -var flag

Full Access
Question # 25

How do you specify a module’s version when publishing it to the public terraform Module Registry?

A.

Configuration it in the module's Terraform code

B.

Mention it on the module's configuration page on the Terraform Module Registry

C.

The Terraform Module Registry does not support versioning modules

D.

Tag a release in the associated repo

Full Access
Question # 26

When using a remote backend or terraform Cloud integration, where does Terraform save resource sate?

A.

In an environment variable

B.

On the disk

C.

In the remote backend or Terraform Cloud

D.

In memory

Full Access
Question # 27

Why does this backend configuration not follow best practices?

A.

An alias meta-argument should be included in backend blocks whenever possible

B.

You should use the local enhanced storage backend whenever possible

C.

You should not store credentials in Terraform configuration

D.

The backend configuration should contain multiple credentials so that more than one user can execute terraform plan and terraform apply

Full Access
Question # 28

Only the user that generated a plan may apply it.

A.

True

B.

False

Full Access
Question # 29

A resource block is shown in the Exhibit space of this page. What is the Terraform resource name of that resource block?

A.

azurerm

B.

azurerm_resource_group

C.

ev

D.

test

Full Access
Question # 30

Infrastructure as Code (laC) can be stored in a version control system along with application code.

A.

True

B.

False

Full Access
Question # 31

You can configure multiple cloud blocks in your Terraform configuration to connect your workspace to both HCP Terraform and your Terraform Enterprise instance.

A.

True

B.

False

Full Access
Question # 32

What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?

A.

terraform refresh

B.

terraform graph

C.

terraform output

D.

terraform show

Full Access
Question # 33

Where in your Terraform configuration do you specify a state backend?

A.

The resource block

B.

The data source block

C.

The terraform block

D.

The provider block

Full Access
Question # 34

Which of the following statements about Terraform modules is not true?

A.

Modules can call other modules

B.

A module is a container for one or more resources

C.

Modules must be publicly accessible

D.

You can call the same module multiple times

Full Access
Question # 35

When do changes invoked by terraform apply take effect?

A.

After Terraform has updated the state file

B.

Once the resource provider has fulfilled the request

C.

Immediately

D.

None of the above are correct

Full Access
Question # 36

terraform init retrieves and caches the configuration for all remote modules.

A.

True

B.

False

Full Access
Question # 37

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?

A.

Terraform will terminate and recreate the VM.

B.

Terraform will create another duplicate VM.

C.

Terraform will apply the VM to the state file.

D.

Nothing

Full Access
Question # 38

Which of the following should you add in the required_providers block to define a provider version constraint?

A.

version

B.

version = "3.1"

C.

version: 3.1

D.

version - 3.1

Full Access
Question # 39

A resource block is shown in the Exhibit section of this page. How would you reference the attribute name of this resource in HCL?

A.

resource.kubernetes_namespace.example.name

B.

kubernetes_namespace.example.name

C.

data.kubernetes.namespace.name

D.

kubernetes_namespace.test.name

Full Access
Question # 40

Which of these ate secure options for storing secrets for connecting to a Terraform remote backend? Choose two correct answers.

A.

A variable file

B.

Defined in Environment variables

C.

Inside the backend block within the Terraform configuration

D.

Defined in a connection configuration outside of Terraform

Full Access
Question # 41

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?

A.

Terraform will prompt you to pick which resource you want to destroy

B.

Terraform will destroy the application server because it is listed first in the code

C.

Terraform will prompt you to confirm that you want to destroy all the infrastructure

D.

Terraform will destroy the main, tf file

E.

Terraform will immediately destroy all the infrastructure

Full Access
Question # 42

Why would you use the -replace flag for terraform apply?

A.

You want Terraform to ignore a resource on the next apply

B.

You want Terraform to destroy all the infrastructure in your workspace

C.

You want to force Terraform to destroy a resource on the next apply

D.

You want to force Terraform to destroy and recreate a resource on the next apply

Full Access
Question # 43

Exhibit:

data "vsphere_datacenter" "dc" {}

resource "vsphere_folder" "parent" {

path = "Production"

type = "vm"

datacenter_id = _________

}

You want to pass the id of the vsphere_datacenter data source to the datacenter_id argument of the vsphere_folder resource. Which reference would you use?

A.

data.vsphere_datacenter.de.id

B.

vsphere_datacenter.dc.id

C.

data.vsphere_datacenter.dc

D.

data.de.id

Full Access
Question # 44

A Terraform backend determines how Terraform loads state and stores updates when you execute which command?

A.

apply

B.

destroy

C.

Both of these are correct.

D.

Neither of these are correct.

Full Access
Question # 45

Variables declared within a module are accessible outside of the module.

A.

True

B.

False

Full Access
Question # 46

In Terraform HCL, an object type of object({name=string, age-number}) would match this value.

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Full Access
Question # 47

How would you output returned values from a child module in the Terraform CLI output?

A.

Declare the output in the root configuration

B.

Declare the output in the child module

C.

Declare the output in both the root and child module

D.

None of the above

Full Access
Question # 48

Which backend does the Terraform CLI use by default?

A.

Depends on the cloud provider configured

B.

HTTP

C.

Remote

D.

Terraform Cloud

E.

Local

Full Access
Question # 49

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.

A.

Lets you version, reuse, and share infrastructure configuration

B.

Provisions the same resources at a lower cost

C.

Secures your credentials

D.

Reduces risk of operator error

E.

Prevents manual modifications to your resources

Full Access
Question # 50

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?

A.

Remove the resource block from your configuration.

B.

Change the value of the count argument on the resource.

C.

Run terraform state rm aws_instance.ubuntu[1].

D.

Use a moved block.

Full Access
Question # 51

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.

A.

A Git repository containing your modules.

B.

Public Terraform module registry.

C.

A subfolder within your workspace.

D.

HCP Terraform/Terraform Cloud private registry.

Full Access
Question # 52

It is best practice to store secret data in the same version control repository as your Terraform configuration.

A.

True

B.

False

Full Access
Question # 53

All modules published on the official Terraform Module Registry have been verified by HasihCorp.

A.

True

B.

False

Full Access
Question # 54

Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.

A.

True

B.

False

Full Access
Question # 55

Terraform configuration (including any module references) can contain only one Terraform provider type.

A.

True

B.

False

Full Access
Question # 56

You can reference a resource created with for_each using a Splat ( *) expression.

A.

True

B.

False

Full Access
Question # 57

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?

A.

Change the referenced value to module.my_network.outputs.vnet_id.

B.

Define the attribute vnet_id as a variable in the networking module.

C.

Change the referenced value to my_network.outputs.vnet_id.

D.

Define the attribute vnet_id as an output in the networking module.

Full Access
Question # 58

Where in your Terraform configuration do you specify remote state storage settings?

A.

The resource block

B.

The provider block

C.

The data block

D.

The terraform block

Full Access
Question # 59

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?

A.

Modify the Terraform configuration to add an import block for both of the virtual machines.

B.

Run a terraform apply -refresh to identify the virtual machine IDs that are already managed by Terraform.

C.

Run terraform state rm on both VMs, then terraform apply to recreate the correct one.

D.

Run terraform state list to find the names of all VMs, then run terraform state show for each of them to find which VM ID Terraform manages.

Full Access
Question # 60

What Terraform command always causes a state file to be updated with changes that might have been made outside of Terraform?

A.

Terraform plan –refresh-only

B.

Terraform show –json

C.

Terraform apply –lock-false

D.

Terraform plan target-state

Full Access
Question # 61

Your team adopts AWS CloudFormation as the standardized method for provisioning public cloud resources. Which scenario presents a challenge for your team?

A.

Building a reusable code base that can deploy resources into any AWS region.

B.

Managing a new application stack built on AWS-native services.

C.

Automating a manual, web console-based provisioning process.

D.

Deploying new infrastructure into Microsoft Azure.

Full Access
Question # 62

When you include a module block in your configuration that references a module from the Terraform Registry, the "version" attribute is required.

A.

True

B.

False

Full Access
Question # 63

You want to know from which paths Terraform is loading providers referenced in your Terraform configuration (* files). You need to enable additional logging messages to find this out. Which of the following would achieve this?

A.

Set verbose for each provider in your Terraform configuration

B.

Set the environment variable TF_LOG_TRACE

C.

Set the environment variable TF_LOG_PATH

D.

Set the environment variable TF_log_TRACE

Full Access
Question # 64

Which of the following is not a valid source path for specifying a module?

A.

source - "github.com/hashicorp/examplePref-ul.0.8M

B.

source = "./module?version=vl.6.0"

C.

source - "hashicorp/consul/aws"

D.

source - "./module"

Full Access
Question # 65

What is one disadvantage of using dynamic blocks in Terraform?

A.

Dynamic blocks can construct repeatable nested blocks

B.

Terraform will run more slowly

C.

They cannot be used to loop through a list of values

D.

They make configuration harder to read and understand

Full Access
Question # 66

You’ve updated your Terraform configuration, and you need to preview the proposed changes to your infrastructure. Which command should you run?

A.

terraform show

B.

terraform plan

C.

terraform validate

D.

terraform get

Full Access
Question # 67

What does Terraform use the .terraform.lock.hc1 file for?

A.

There is no such file

B.

Tracking specific provider dependencies

C.

Preventing Terraform runs from occurring

D.

Storing references to workspaces which are locked

Full Access
Question # 68

Which of the following is not a valid Terraform collection type?

A.

Tree

B.

Map

C.

List

D.

set

Full Access
Question # 69

Using the terraform state rm command against a resource will destroy it.

A.

True

B.

False

Full Access
Question # 70

When using multiple configuration of the same Terraform provider, what meta-argument must you include in any non-default provider configurations?

A.

Alias

B.

Id

C.

Depends_on

D.

name

Full Access
Question # 71

If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?

A.

Run terraform refresh

B.

It will happen automatically

C.

Manually update the state fire

D.

Run terraform import

Full Access
Question # 72

Which of these statements about HCP Terraform/Terraform Cloud workspaces is false?

A.

They can securely store cloud credentials.

B.

They have role-based access controls.

C.

Plans and applies can be triggered via version control system integrations.

D.

You must use the CLI to switch between workspaces.

Full Access
Question # 73

When do you need to explicitly execute Terraform in refresh-only mode?

A.

Before every terraform plan.

B.

Before every terraform apply.

C.

Before every terraform import.

D.

None of the above.

Full Access
Question # 74

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?

A.

aws_instance.web[2].name

B.

aws_instance.web.*.name

C.

aws_instance.web[l].name

D.

aws_instance.web[l]

E.

element(aws_instance.web, 2)

Full Access
Question # 75

Which of these commands makes your code more human readable?

A.

Terraform validate

B.

Terraform output

C.

Terraform show

D.

Terraform file

Full Access
Question # 76

You created infrastructure outside the Terraform workflow that you now want to manage using Terraform. Which command brings the infrastructure into Terraform state?

A.

terraform get

B.

terraform refresh

C.

terraform import

D.

terraform init

Full Access
Question # 77

A Terraform provider is NOT responsible for:

A.

Exposing resources and data sources based on an APUI

B.

Managing actions to take based on resources differences

C.

Understanding API interactions with some service

D.

Provisioning infrastructure in multiple

Full Access
Question # 78

Which of the following isnotan advantage of using Infrastructure as Code (IaC) operations?

A.

Self-service infrastructure deployment.

B.

Modify a count parameter to scale resources.

C.

API-driven workflows.

D.

Troubleshoot via a Linux diff command.

E.

Public cloud console configuration workflows.

Full Access
Question # 79

Which of the following is not a key principle of infrastructure as code?

A.

Self-describing infrastructure

B.

Idempotence

C.

Versioned infrastructure

D.

Golden images

Full Access
Question # 80

A Terraform local value can reference other Terraform local values.

A.

True

B.

False

Full Access
Question # 81

Which Terraform collection type should you use to store key/value pairs?

A.

Set

B.

Map

C.

Tuple

D.

list

Full Access
Question # 82

If a module declares a variable with a default, that variable must also be defined within the module.

A.

True

B.

False

Full Access
Question # 83

Which of these statements about Terraform Cloud workspaces is false?

A.

They have role-based access controls

B.

You must use the CLI to switch between workspaces

C.

Plans and applies can be triggered via version control system integrations

D.

They can securely store cloud credentials

Full Access
Question # 84

Which of the following does terraform apply change after you approve the execution plan? (Choose two.)

A.

Cloud infrastructure

B.

The .terraform directory

C.

The execution plan

D.

State file

E.

Terraform code

Full Access
Question # 85

A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?

A.

Tear down the entire workspace's infrastructure and rebuild it.

B.

Build a completely brand new set of infrastructure.

C.

Rebuild only the instances that were deleted.

D.

Stop and generate an error message about the missing instances.

Full Access
Question # 86

Which of the following is not a valid string function in Terraform?

A.

chomp

B.

join

C.

slice

D.

split

Full Access
Question # 87

Which two steps are required to provision new infrastructure in the Terraform workflow? (Pick the 2 correct responses below.)

A.

Import

B.

Apply

C.

Validate

D.

Plan

E.

Init

Full Access
Question # 88

Which is a benefit of using infrastructure as code (IaC) tools compared to native platform APIs?

A.

IaC allows you to write each API call required to reach the desired configuration.

B.

IaC calls native command line tools, which are more efficient than API calls.

C.

IaC configurations define the current state of infrastructure, which allows you to identify the correct API calls to make changes.

D.

IaC configurations define the end state of the infrastructure without having to write API calls to reach the desired configuration.

Full Access
Question # 89

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?

A.

aws_ami.web.id

B.

web.id

C.

data.aws_ami.web.id

D.

data.web.id

Full Access