Spring Sale Discount Flat 70% Offer - Ends in 0d 00h 00m 00s - Coupon code: 70diswrap

HashiCorp Terraform-Associate-004 Dumps

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

Question 1

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?

Options:

A.

Local values

B.

Count arguments

C.

Collection functions

D.

Dynamic blocks

Question 2

Which command generates DOT (Document Template) formatted data to visualize Terraform dependencies?

Options:

A.

terraform graph

B.

terraform show

C.

terraform refresh

D.

terraform output

Question 3

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 the 3 correct responses)

Options:

A.

In an HCP Terraform/Terraform Cloud variable, with the sensitive option checked.

B.

In HashiCorp Vault.

C.

In a terraform.tfvars file, securely managed and shared with your team.

D.

In a terraform.tfvars file, checked into your version control system.

E.

In a plaintext document on a shared drive.

Question 4

Terraform configuration can only call modules from the public registry.

Options:

A.

True

B.

False

Question 5

Running terraform fmt without any flags in a directory with Terraform configuration files check the formatting of those files without changing their contents.

Options:

A.

True

B.

False

Question 6

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

Options:

A.

True

B.

False

Question 7

Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.

Options:

A.

Automated infrastructure deployment visualization.

B.

A web-based user interface (UI).

C.

Automatic backups of configuration and state.

D.

Remote state storage.

Question 8

A provider configuration block is required in every Terraform configuration.

Example:

as

Options:

A.

True

B.

False

Question 9

Terraform providers are always installed from the Internet.

Options:

A.

True

B.

False

Question 10

terraform apply will fail if you have not run terraform plan first to update the plan output.

Options:

A.

True

B.

False

Question 11

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

Options:

A.

version

B.

version = " 3.1 "

C.

version: 3.1

D.

version - 3.1

Question 12

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?

Options:

A.

Make the change via the public cloud API endpoint.

B.

Submit a pull request and wait for an approved merge of the proposed changes.

C.

Clone the repository containing your infrastructure code and then run the code.

D.

Use the public cloud console to make the change after approval.

E.

Make the change programmatically via the cloud CLI.

Question 13

Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.

Options:

A.

Plan

B.

Import

C.

Alidate

D.

Init

E.

apply

Question 14

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

Options:

A.

Cloud infrastructure

B.

The .terraform directory

C.

The execution plan

D.

State file

E.

Terraform code

Question 15

Outside of the required_providers block, Terraform configurations always refer to providers by their local names.

Options:

A.

True

B.

False

Question 16

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

Options:

A.

The resource block

B.

The provider block

C.

The data block

D.

The terraform block

Question 17

How does Terraform determine dependencies between resources?

Options:

A.

Terraform requires resource dependencies to be defined as modules and sourced in order

B.

Terraform automatically builds a resource graph based on resources provisioners, special meta-parameters, and the stale file (if present}

C.

Terraform requires resources in a configuration to be listed m the order they will be created to determine dependencies

D.

Terraform requires all dependencies between resources to be specified using the depends_on parameter

Question 18

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

Options:

A.

True

B.

False

Question 19

When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)

Options:

A.

When you change a Terraform-managed resource via the Azure Cloud Console, Terraform updates the state file to reflect the change during the next plan or apply

B.

Changing resources via the Azure Cloud Console records the change in the current state file

C.

When you change a resource via the Azure Cloud Console, Terraform records the changes in a new state file

D.

Changing resources via the Azure Cloud Console does not update current state file

Question 20

Which argument can you use toprevent unexpected updatesto a module ' s configuration when calling Terraform Registry modules?

Options:

A.

source

B.

count

C.

version

D.

lifecycle

Question 21

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?

Options:

A.

servers = num_servers

B.

servers = var(num_servers)

C.

servers = var.num_servers

D.

servers = ${var.num_servers}

Question 22

Terraform requires using a different provider for each cloud provider where you want to deploy resources.

Options:

A.

True

B.

False

Question 23

What functionality do providers offer in Terraform?(Pick 3 correct responses)

Options:

A.

Interact with cloud provider APIs.

B.

Provision resources for on-premises infrastructure services.

C.

Group a collection of Terraform configuration files that map to a single state file.

D.

Provision resources for public cloud infrastructure services.

E.

Enforce security and compliance policies.

Question 24

What value does the Terraform Cloud private registry provide over the public Terraform Module Registry?

Options:

A.

The ability to share modules publicly with any user of Terraform

B.

The ability to restrict modules to members of Terraform Cloud or Enterprise organizations

C.

The ability to tag modules by version or release

D.

The ability to share modules with public Terraform users and members of Terraform Cloud Organizations

Question 25

Which of the following is not a way to trigger terraform destroy?

Options:

A.

Using the destroy command with auto-approve.

B.

Passing --destroy at the end of a plan request.

C.

Running terraform destroy from the correct directory and then typing yes when prompted in the CLI.

Question 26

Which of these are features of HCP Terraform/Terraform Cloud? (Pick the 2 correct responses)

Options:

A.

Automatic backups of configuration and state.

B.

Remote state storage.

C.

Automated infrastructure deployment visualization.

D.

A web-based user interface (UI).

Question 27

Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?

Options:

A.

terraform state list ‘provider_type.name’

B.

terraform state show ‘provider_type.name’

C.

terraform get ‘provider_type.name’

D.

terraform state list

Question 28

A terraform apply can not _________ infrastructure.

Options:

A.

change

B.

destroy

C.

provision

D.

import

Question 29

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

Options:

A.

Run terraform refresh

B.

It will happen automatically

C.

Manually update the state fire

D.

Run terraform import

Question 30

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

Options:

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.

Question 31

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

Options:

A.

True

B.

False

Question 32

Terraform providers are part of the Terraform core binary.

Options:

A.

True

B.

False

Question 33

Which of the following is not a benefit of adopting infrastructure as code?

Options:

A.

Versioning

B.

A Graphical User Interface

C.

Reusability of code

D.

Automation

Question 34

terraform plan updates your state file.

Options:

A.

True

B.

False

Question 35

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?

Options:

A.

Add a depends_on argument to the azurerm_linux_web_app.

B.

Add a create_before_destroy argument to the azurerm_role_assignment.

C.

Change the order of the azurerm_linux_web_app and azurerm_role_assignment blocks.

D.

Add a count argument to both resources.

Question 36

You have a simple Terraform configuration containing one VM (virtual machine) in a cloud provider. You run terraform apply and the VM is created successfully. What will happen if you run terraform apply again immediately afterwards without changing any Terraform code?

Options:

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.

Terraform will take no action.

Question 37

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

Options:

A.

terraform refresh

B.

terraform graph

C.

terraform output

D.

terraform show

Question 38

The -refresh-only parameter will update your state file when used with terraform plan.

Options:

A.

True

B.

False

Question 39

What is modified when executing Terraform inrefresh-only mode?

Options:

A.

Your Terraform configuration.

B.

Your Terraform plan.

C.

Your state file.

D.

Your cloud infrastructure.

Question 40

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

Options:

A.

True

B.

False

Question 41

How is terraform import run?

Options:

A.

As a part of terraform init

B.

As a part of terraform plan

C.

As a part of terraform refresh

D.

By an explicit call

E.

All of the above

Question 42

You want to define a single input variable to capture configuration values for a server. The values must represent memory as a number, and the server name as a string.

Which variable type could you use for this input?

Options:

A.

List

B.

Object

C.

Map

D.

Terraform does not support complex input variables of different types

Question 43

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

Options:

A.

True

B.

False

Question 44

Terraform encrypts sensitive values stored in your state file.

Options:

A.

True

B.

False

Question 45

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.

Options:

A.

True

B.

False

Question 46

You are using a networking module in your Terraform configuration with the name label my-network. In your main configuration you have the following code:

When you run terraform validate, you get the following error:

What must you do to successfully retrieve this value from your networking module?

Options:

A.

Change the reference value to my-network,outputs,vmet_id

B.

Define the attribute vmet_id as a variable in the networking modeule

C.

Define the attribute vnet_id as an output in the networking module

D.

Change the reference value module.my,network,outputs,vnet_id

Question 47

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?

Options:

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)

Question 48

When do changes invoked by terraform apply take effect?

Options:

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

Question 49

Which of these are benefits of using Sentinel with HCP Terraform/Terraform Cloud? (Pick the 3 correct responses)

Options:

A.

You can enforce a list of approved AWS AMIs.

B.

Sentinel Policies can be written in HashiCorp Configuration Language (HCL).

C.

You can check out and check in cloud access keys.

D.

Policy-as-code can enforce security best practices.

Question 50

Exhibit.

You need to deploy resources into two different regions in the same Terraform configuration. To do this, you declare multiple provider configurations as shown in the Exhibit space on this page.

What meta-argument do you need to configure in a resource block to deploy the resource to the us-west-2 AWS region?

Options:

A.

provider = aws.west

B.

alias = aws.west

C.

provider = west

D.

alias = west

Question 51

A module can always refer to all variables declared in its parent module.

Options:

A.

True

B.

False

Question 52

terraform apply is failing with the following error. What next step should you take to determine the root cause of the problem?

Error:

yaml

CopyEdit

Error loading state: AccessDenied: Access Denied

status code: 403, request id: 288766CE5CCA24A0, host id: web.example.com

Options:

A.

Run terraform login to reauthenticate with the provider.

B.

Set TF_LOG=DEBUG.

C.

Review /var/log/terraform.log for error messages.

D.

Review syslog for Terraform error messages.

Question 53

You cannot install third party plugins using terraform init.

Options:

A.

True

B.

False

Question 54

Which of these commands makes your code more human readable?

Options:

A.

Terraform validate

B.

Terraform output

C.

Terraform show

D.

Terraform file

Question 55

Only the user that generated a terraform plan may apply it.

Options:

A.

True

B.

False

Question 56

What does this code do?

terraform { required_providers { aws = " > = 3.0 " }}

Options:

A.

Requires any version of the AWS provider > = 3.0 and < 4.0

B.

Requires any version of the AWS provider > = 3.0

C.

Requires any version of the AWS provider > = 3.0 major release. like 4.1

D.

Requires any version of the AWS provider > 3.0

Question 57

Which command doesnotcause Terraform to refresh its state?

Options:

A.

terraform state list

B.

terraform plan

C.

terraform apply

D.

terraform destroy

Question 58

If you don’t use the local Terraform backend, where else can Terraform save resource state?

Options:

A.

In a remote location configured in the terraform block, such as HCP Terraform or a cloud storage system.

B.

In a remote location configured in the -terraformrc file, such as HCP Terraform or a cloud storage system.

C.

In memory.

D.

In an environment variable.

Question 59

A child module can always access variables declared in its parent module.

Options:

A.

True

B.

False

Question 60

You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are standardizing with Terraform and want to manage these VMs using Terraform instead. What are the two things you must do to achieve this? Choose two correct answers.

Options:

A.

Run the terraform Import-gcp command

B.

Write Terraform configuration for the existing VMs

C.

Use the terraform import command for the existing VMs

D.

Provision new VMs using Terraform with the same VM names

Question 61

Terraform variable names are saved in the state file.

Options:

A.

True

B.

False

Question 62

What is terraform plan -refresh-only intended to detect?

Options:

A.

Terraform configuration code changes

B.

Corrupt state files

C.

State file drift

D.

Empty state files

Question 63

Define the purpose of state in Terraform.

Options:

A.

State maps real world resources to your configuration and keeps track of metadata

B.

State lets you enforce resource configurations that relate to compliance policies

C.

State stores variables and lets you quickly reuse existing code

D.

State codifies the dependencies of related resources

Question 64

Which of the following are advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.

Options:

A.

Prevents manual modifications to your resources

B.

Lets you version, reuse, and share infrastructure configuration

C.

Secures your credentials

D.

Provisions the same resources at a lower cost

E.

Reduces risk of operator error

Question 65

What is one disadvantage of using dynamic blocks in Terraform?

Options:

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

Question 66

What functionality do providers offer in Terraform? (Pick the 3 correct responses below.)

Options:

A.

Group a collection of Terraform configuration files that map to a single state file.

B.

Provision resources for on-premises infrastructure services.

C.

Provision resources for public cloud infrastructure services.

D.

Interact with cloud provider APIs.

E.

Enforce security and compliance policies.

Question 67

What does terraform import do?

Options:

A.

Imports existing resources into the state file

B.

Imports all infrastructure from a given cloud provider

C.

Imports a new Terraform module

D.

Imports clean copies of tainted resources

E.

None of the above

Question 68

Any user can publish modules to the public Terraform Module Registry.

Options:

A.

True

B.

False

Question 69

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.

You have a saved execution plan containing desired changes for infrastructure managed by Terraform. After running terraform apply my.tfplan, you receive the error shown. How can you apply the desired changes? (Pick the 2 correct responses below.)

Options:

A.

Generate a new execution plan file with terraform plan, and apply the new plan.

B.

Run terraform apply without the saved execution plan.

C.

Force the apply command by adding the flag -lock=false.

D.

Refresh the current state data using the -refresh-only flag.

E.

Update the current plan file using the terraform state push command.

Question 70

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

Options:

A.

Import

B.

Apply

C.

Validate

D.

Plan

E.

Init

Question 71

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?

Options:

A.

Remove the old resource from your configuration and re-import it.

B.

Run terraform apply -refresh-only.

C.

Do nothing — Terraform will automatically update the state.

D.

Add a moved block to your configuration.

Question 72

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.

Options:

A.

True

B.

False

Question 73

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?

Options:

A.

Use a module.

B.

Add an output value.

C.

Add a local value.

D.

Use a data source.

Question 74

You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code. What is the best method to quickly find the IP address of the resource you deployed?

Options:

A.

In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file

B.

Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address

C.

Run terraform output ip_address to view the result

D.

Run terraform destroy then terraform apply and look for the IP address in stdout

Question 75

Which backend does the Terraform CLI use by default?

Options:

A.

Depends on the cloud provider configured

B.

HTTP

C.

Remote

D.

Terraform Cloud

E.

Local

Question 76

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?

Options:

A.

aws_ami.web.id

B.

web.id

C.

data.aws_ami.web.id

D.

data.web.id

Question 77

terraform validate uses provider APIs to verify your infrastructure settings.

Options:

A.

True

B.

False

Question 78

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.

Options:

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.

Question 79

What is the purpose of the terraform.lock.hcl file in Terraform?

Options:

A.

There is no such file.

B.

Storing references to workspaces, which are locked.

C.

Preventing Terraform runs from occurring.

D.

Tracking specific provider dependencies.

Question 80

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

Options:

A.

True

B.

False

Question 81

You have multiple team members collaborating on infrastructure as code (IaC) using Terraform, and want to apply formatting standards for readability.

How can you format Terraform HCL (HashiCorp Configuration Language) code according to standard Terraform style convention?

Options:

A.

Run the terraform fmt command during the code linting phase of your CI/CD process Most Voted

B.

Designate one person in each team to review and format everyone ' s code

C.

Manually apply two spaces indentation and align equal sign " = " characters in every Terraform file (*.tf)

D.

Write a shell script to transform Terraform files using tools such as AWK, Python, and sed

Question 82

Which of the following locations can Terraform use as aprivate sourcefor modules?(Pick 2 correct responses)

Options:

A.

Public repository on GitHub.

B.

Public Terraform Registry.

C.

Internally hosted VCS (Version Control System) platform.

D.

Private repository on GitHub.

Question 83

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

Options:

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.

Question 84

You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account already contains 15 virtual machines (VM). You develop a Terraform configuration containing one VM. perform terraform apply, and see that your VM was created successfully. What should you do to delete the newly-created VM with Terraform?

Options:

A.

The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM.

B.

Delete the Terraform state file and execute terraform apply.

C.

The Terraform state file only contains the one new VM. Execute terraform destroy.

D.

Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state file.

Question 85

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

Options:

A.

True

B.

False

Question 86

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.

Options:

Question 87

What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.

Options:

A.

You can restrict specific resource configurations, such as disallowing the use of CIDR=0.0.0.0/0.

B.

You can check out and check in cloud access keys

C.

Sentinel Policies can be written in HashiCorp Configuration Language (HCL)

D.

Policy-as-code can enforce security best practices

E.

You can enforce a list of approved AWS AMIs

Question 88

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

Options:

A.

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

B.

You want Terraform to ignore a resource on the next apply.

C.

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

D.

You want Terraform to destroy all the infrastructure in your workspace.

Question 89

You have developed a new cloud-based service that uses proprietary APIs and want to use Terraform to create, manage, and delete users from the service. How can Terraform interact with the service?

Options:

A.

Terraform can manage users for any service that is hosted on a public cloud provider.

B.

Develop and publish a custom provider to interact with the service using its proprietary APIs.

Question 90

When you use a remote backend that needs authentication, HashiCorp recommends that you:

Options:

A.

Write the authentication credentials in the Terraform configuration files

B.

Keep the Terraform configuration files in a secret store

C.

Push your Terraform configuration to an encrypted git repository

D.

Use partial configuration to load the authentication credentials outside of the Terraform code

Question 91

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

Options:

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

Question 92

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

Options:

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.

Question 93

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?

Options:

A.

Terraform data sources

B.

Terraform local values

C.

Terraform modules

D.

Terraform workspaces

E.

None of the above

Question 94

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.

Options:

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

Question 95

A Terraform local value can reference other Terraform local values.

Options:

A.

True

B.

False

Page: 1 / 32
Total 318 questions