Terraform Associate Certified Official Practice Test Terraform-Associate-003 - Apr-2025 [Q109-Q130]

Share

Terraform Associate Certified Official Practice Test Terraform-Associate-003 - Apr-2025

Ace HashiCorp Terraform-Associate-003 Certification with Actual Questions Apr 30, 2025 Updated


HashiCorp Terraform-Associate-003 Exam Syllabus Topics:

TopicDetails
Topic 1
  • Create, maintain, and use Terraform modules: In this section of the exam, candidates are tested for creating a module, using a module in configuration, and topics such as refactoring an existing configuration into modules.
Topic 2
  • Develop and troubleshoot dynamic configuration: This section deals with topics such as using language features to validate configuration query providers using data sources, computing and interpolating data using HCL functions, and using meta-arguments in configuration.
Topic 3
  • Collaborate on infrastructure as code using HCP Terraform: In this section, the topics covered include analyzing the HCP Terraform run workflow, the role of HCP Terraform workspaces and their configuration options, and the management of provider credentials in HCP Terraform.

 

NEW QUESTION # 109
Which of the following arguments are required when declaring a Terraform output?

  • A. default
  • B. sensitive
  • C. description
  • D. value

Answer: D

Explanation:
When declaring a Terraform output, the value argument is required. Outputs are a way to extract information from Terraform-managed infrastructure, and the value argument specifies what data will be outputted. While other arguments like description and sensitive can provide additional context or security around the output, value is the only mandatory argument needed to define an output.
References = The requirement of the value argument for outputs is specified in Terraform's official documentation, which provides guidelines on defining and using outputs in Terraform configurations.


NEW QUESTION # 110
Which are forbidden actions when the terraform state file is locked? Choose three correct answers.

  • A. Terraform validate
  • B. Terraform validate
  • C. Terraform for
  • D. Terraform state list
  • E. Terraform destroy
  • F. Terraform apply

Answer: B,E,F

Explanation:
The terraform state file is locked when a Terraform operation that could write state is in progress. This prevents concurrent state operations that could corrupt the state. The forbidden actions when the state file is locked are those that could write state, such as terraform apply, terraform destroy, terraform refresh, terraform taint, terraform untaint, terraform import, and terraform state *. The terraform validate command is also forbidden, because it requires an initialized working directory with the state file. The allowed actions when the state file is locked are those that only read state, such as terraform plan, terraform show, terraform output, and terraform console. Reference = [State Locking] and [Command: validate]


NEW QUESTION # 111
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?

  • A. Write a shell script to transform Terraform files using tools such as AWK, Python, and sed
  • B. Manually apply two spaces indentation and align equal sign "=" characters in every Terraform file (*.tf)
  • C. Run the terraform fmt command during the code linting phase of your CI/CD process Most Voted
  • D. Designate one person in each team to review and format everyone's code

Answer: C

Explanation:
The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability. Running this command on your configuration files before committing them to source control can help ensure consistency of style between different Terraform codebases, and can also make diffs easier to read. You can also use the -check and -diff options to check if the files are formatted and display the formatting changes respectively2. Running the terraform fmt command during the code linting phase of your CI/CD process can help automate this process and enforce the formatting standards for your team. Reference = [Command: fmt]2


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

  • A. Plan
  • B. Alidate
  • C. Import
  • D. Init
  • E. apply

Answer: D,E

Explanation:
The two steps that are required to provision new infrastructure in the Terraform workflow are init and apply. The terraform init command initializes a working directory containing Terraform configuration files. It downloads and installs the provider plugins that are needed for the configuration, and prepares the backend for storing the state. The terraform apply command applies the changes required to reach the desired state of the configuration, as described by the resource definitions in the configuration files. It shows a plan of the proposed changes and asks for confirmation before making any changes to the infrastructure. Reference = [The Core Terraform Workflow], [Initialize a Terraform working directory with init], [Apply Terraform Configuration with apply]


NEW QUESTION # 113
Which of the following is not a key principle of infrastructure as code?

  • A. Idempotence
  • B. Versioned infrastructure
  • C. Self-describing infrastructure
  • D. Golden images

Answer: D

Explanation:
Explanation
The key principle of infrastructure as code that is not listed among the options is golden images. Golden images are pre-configured, ready-to-use virtual machine images that contain a specific set of software and configuration. They are often used to create multiple identical instances of the same environment, such as for testing or production. However, golden images are not a principle of infrastructure as code, but rather a technique that can be used with or without infrastructure as code. The other options are all key principles of infrastructure as code, as explained below:
Self-describing infrastructure: This means that the infrastructure is defined in code that describes its desired state, rather than in scripts that describe the steps to create it. This makes the infrastructure easier to understand, maintain, and reproduce.
Idempotence: This means that applying the same infrastructure code multiple times will always result in the same state, regardless of the initial state. This makes the infrastructure consistent and predictable, and avoids errors or conflicts caused by repeated actions.
Versioned infrastructure: This means that the infrastructure code is stored in a version control system, such as Git, that tracks the changes and history of the code. This makes the infrastructure code reusable, auditable, and collaborative, and enables practices such as branching, merging, and rollback. References
= [Introduction to Infrastructure as Code with Terraform], [Infrastructure as Code in a Private or Public Cloud]


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

  • A. True
  • B. False

Answer: A

Explanation:
Infrastructure as Code (IaC) can indeed be stored in a version control system along with application code. This practice is a fundamental principle of modern infrastructure management, allowing teams to apply software development practices like versioning, peer review, and CI/CD to infrastructure management. Storing IaC configurations in version control facilitates collaboration, history tracking, and change management.References= While this concept is a foundational aspect of IaC and is widely accepted in the industry, direct references from the HashiCorp Terraform Associate (003) study materials were not found in the provided files. However, this practice is encouraged in Terraform's best practices and various HashiCorp learning resources.


NEW QUESTION # 115
As a developer, you want to ensure your plugins are up to date with the latest versions. Which Terraform command should you use?

  • A. terraform apply -upgrade
  • B. terraform providers -upgrade
  • C. terraform init -upgrade
  • D. terraform refresh -upgrade

Answer: C

Explanation:
Explanation
This command will upgrade the plugins to the latest acceptable version within the version constraints specified in the configuration. The other commands do not have an -upgrade option.


NEW QUESTION # 116
Which of the following arguments are required when declaring a Terraform output?

  • A. default
  • B. sensitive
  • C. description
  • D. value

Answer: D

Explanation:
When declaring a Terraform output, thevalueargument is required. Outputs are a way to extract information from Terraform-managed infrastructure, and thevalueargument specifies what data will be outputted. While other arguments likedescriptionandsensitivecan provide additional context or security around the output, valueis the only mandatory argument needed to define an output.References= The requirement of thevalue argument for outputs is specified in Terraform's official documentation, which provides guidelines on defining and using outputs in Terraform configurations.


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

  • A. Defined in a connection configuration outside of Terraform
  • B. A variable file
  • C. Defined in Environment variables
  • D. Inside the backend block within the Terraform configuration

Answer: A,C

Explanation:
Environment variables and connection configurations outside of Terraform are secure options for storing secrets for connecting to a Terraform remote backend. Environment variables can be used to set values for input variables that contain secrets, such as backend access keys or tokens. Terraform will read environment variables that start with TF_VAR_ and match the name of an input variable. For example, if you have an input variable called backend_token, you can set its value with the environment variable TF_VAR_backend_token1.
Connection configurations outside of Terraform are files or scripts that provide credentials or other information for Terraform to connect to a remote backend. For example, you can use a credentials file for the S3 backend2, or a shell script for the HTTP backend3. These files or scripts are not part of the Terraform configuration and can be stored securely in a separate location. The other options are not secure for storing secrets. A variable file is a file that contains values for input variables. Variable files are usually stored in the same directory as the Terraform configuration or in a version control system. This exposes the secrets to anyone who can access the files or the repository. You should not store secrets in variable files1. Inside the backend block within the Terraform configuration is where you specify the type and settings of the remote backend. The backend block is part of the Terraform configuration and is usually stored in a version control system. This exposes the secrets to anyone who can access the configuration or the repository. You should not store secrets in the backend block4. References = [Terraform Input Variables]1, [Backend Type: s3]2,
[Backend Type: http]3, [Backend Configuration]4


NEW QUESTION # 118
Which of the following command would be use to access all of the attributes and details of a resource managed by Terraform?

  • A. Terraform state show ' provider_type_name
  • B. Terraform state list provider_type_name
  • C. Terraform get provider_type_name
  • D. Terraform state list

Answer: A

Explanation:
This is the command that you would use to access all of the attributes and details of a resource managed by Terraform, by providing the resource address as an argument. For example, terraform state show 'aws_instance.example' will show you all the information about the AWS instance named example.


NEW QUESTION # 119
Define the purpose of state in Terraform.

  • A. State codifies the dependencies of related resources
  • 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 maps real world resources to your configuration and keeps track of metadata

Answer: D

Explanation:
The purpose of state in Terraform is to keep track of the real-world resources managed by Terraform, mapping them to the configuration. The state file contains metadata about these resources, such as resource IDs and other important attributes, which Terraform uses to plan and manage infrastructure changes. The state enables Terraform to know what resources are managed by which configurations and helps in maintaining the desired state of the infrastructure.References= This role of state in Terraform is outlined in Terraform's official documentation,emphasizing its function in mapping configuration to real-world resources and storing vital metadata .


NEW QUESTION # 120
Module version is required to reference a module on the Terraform Module Registry.

  • A. False
  • B. True

Answer: A

Explanation:
Module version is optional to reference a module on the Terraform Module Registry. If you omit the version constraint, Terraform will automatically use the latest available version of the module


NEW QUESTION # 121
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.

Answer:

Explanation:
Terraform.tfstate
Explanation:
The name of the default file where Terraform stores the state is terraform.tfstate. This file contains a JSON representation of the current state of the infrastructure managed by Terraform. Terraform uses this file to track the metadata and attributes of the resources, and to plan and apply changes. By default, Terraform stores the state file locally in the same directory as the configuration files, but it can also be configured to store the state remotely in a backend. References = [Terraform State], [State File Format]


NEW QUESTION # 122
How would you output returned values from a child module in the Terraform CLI output?

  • A. Declare the output in the root configuration
  • B. None of the above
  • C. Declare the output in both the root and child module
  • D. Declare the output in the child module

Answer: C

Explanation:
To output returned values from a child module in the Terraform CLI output, you need to declare the output in both the child module and the root module. The child module output will return the value to the root module, and the root module output will display the value in the CLI. References = [Terraform Outputs]


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

  • A. Terraform code
  • B. State file
  • C. The .terraform directory
  • D. The execution plan
  • E. Cloud infrastructure Most Voted

Answer: B,E

Explanation:
The terraform apply command changes both the cloud infrastructure and the state file after you approve the execution plan. The command creates, updates, or destroys the infrastructure resources to match the configuration. It also updates the state file to reflect the new state of the infrastructure. The .terraform directory, the execution plan, and the Terraform code are not changed by the terraform apply command. Reference = Command: apply and Purpose of Terraform State


NEW QUESTION # 124
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?

  • A. terraform state
  • B. terraform refresh
  • C. terraform init
  • D. terraform push

Answer: C

Explanation:
This command will initialize the new backend and prompt you to migrate the existing state file to the new location3. The other commands are not relevant for this task.


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

  • A. False
  • B. True

Answer: A

Explanation:
Explanation
Outside of the required_providers block, Terraform configurations can refer to providers by either their local names or their source addresses. The local name is a short name that can be used throughout the configuration, while the source address is a global identifier for the provider in the format registry.terraform.io/namespace/type. For example, you can use either aws or registry.terraform.io/hashicorp/aws to refer to the AWS provider.


NEW QUESTION # 126
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.

  • A. False
  • B. True

Answer: A

Explanation:
Explanation
Terraform can manage resource dependencies implicitly or explicitly. Implicit dependencies are created when a resource references another resource or data source in its arguments. Terraform can infer the dependency from the reference and create or destroy the resources in the correct order. Explicit dependencies are created when you use the depends_on argument to specify that a resource depends on another resource or module.
This is useful when Terraform cannot infer the dependency from the configuration or when you need to create a dependency for some reason outside of Terraform's scope. References = : Create resource dependencies : Terraform Resource Dependencies Explained


NEW QUESTION # 127
Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.

  • A. False
  • B. True

Answer: A

Explanation:
Terraform can manage resource dependencies implicitly or explicitly. Implicit dependencies are created when a resource references another resource or data source in its arguments. Terraform can infer the dependency from the reference and create or destroy the resources in the correct order. Explicit dependencies are created when you use the depends_on argument to specify that a resource depends on another resource or module. This is useful when Terraform cannot infer the dependency from the configuration or when you need to create a dependency for some reason outside of Terraform's scope. Reference = : Create resource dependencies : Terraform Resource Dependencies Explained


NEW QUESTION # 128
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files.
How can you protect that data?

  • A. Edit your state file to scrub out the sensitive data
  • B. Store the state in an encrypted backend
  • C. Always store your secrets in a secrets.tfvars file
  • D. Delete the state file every time you run Terraform

Answer: B

Explanation:
Explanation
This is a secure way to protect sensitive data in the state file, as it will be encrypted at rest and in transit2. The other options are not recommended, as they could lead to data loss, errors, or security breaches.


NEW QUESTION # 129
Which command add existing resources into Terraform state?

  • A. Terraform import
  • B. All of these
  • C. Terraform refresh
  • D. Terraform init
  • E. Terraform plan

Answer: A

Explanation:
Explanation
This is the command that can add existing resources into Terraform state, by matching them with the corresponding configuration blocks in your files.


NEW QUESTION # 130
......

Try Free and Start Using Realistic Verified Terraform-Associate-003 Dumps Instantly.: https://www.pass4guide.com/Terraform-Associate-003-exam-guide-torrent.html

2025 The Most Effective Terraform-Associate-003 with 195 Questions Answers: https://drive.google.com/open?id=1fNfDpIPShSGvowTQauStyF2K7mk6yiRn