HashiCorp Terraform Associate 003 Practice Test - Questions Answers, Page 3
List of questions
Related questions
Question 21

Which task does terraform init not perform?
Explanation:
The terraform init command is used to initialize a working directory containing Terraform configuration files. This command performs several different initialization steps to prepare the current working directory for use with Terraform, which includes initializing the backend, installing provider plugins, and copying any modules referenced in the configuration. However, it does not validate whether all required variables are present; that is a task performed by terraform plan or terraform apply1.
Reference = This information can be verified from the official Terraform documentation on the terraform init command provided by HashiCorp Developer1.
Question 22

Which of the following is not a benefit of adopting infrastructure as code?
Explanation:
Infrastructure as Code (IaC) provides several benefits, including the ability to version control infrastructure, reuse code, and automate infrastructure management. However, IaC is typically associated with declarative configuration files and does not inherently provide a graphical user interface (GUI). A GUI is a feature that may be provided by specific tools or platforms built on top of IaC principles but is not a direct benefit of IaC itself1.
Reference = The benefits of IaC can be verified from the official HashiCorp documentation on ''What is Infrastructure as Code with Terraform?'' provided by HashiCorp Developer1.
Question 23

Which of these is true about Terraform's plugin-based architecture?
Explanation:
Terraform is built on a plugin-based architecture, enabling developers to extend Terraform by writing new plugins or compiling modified versions of existing plugins1. Terraform plugins are executable binaries written in Go that expose an implementation for a specific service, such as a cloud resource, SaaS platform, or API2. If there is no existing provider for your API, you can create one using the Terraform Plugin SDK3 or the Terraform Plugin Framework4. Reference =
* 1: Plugin Development - How Terraform Works With Plugins | Terraform | HashiCorp Developer
* 2: Lab: Terraform Plug-in Based Architecture - GitHub
* 3: Terraform Plugin SDK - Terraform by HashiCorp
* 4: HashiCorp Terraform Plugin Framework Now Generally Available
Question 24

The Terraform binary version and provider versions must match each other in a single configuration.
Explanation:
The Terraform binary version and provider versions do not have to match each other in a single configuration. Terraform allows you to specify provider version constraints in the configuration's terraform block, which can be different from the Terraform binary version1. Terraform will use the newest version of the provider that meets the configuration's version constraints2. You can also use the dependency lock file to ensure Terraform is using the correct provider version3. Reference =
* 1: Providers - Configuration Language | Terraform | HashiCorp Developer
* 2: Multiple provider versions with Terraform - Stack Overflow
* 3: Lock and upgrade provider versions | Terraform - HashiCorp Developer
Question 25

Which of the following is not true of Terraform providers?
Explanation:
All of the statements are true of Terraform providers. Terraform providers are plugins that enable Terraform to interact with various APIs and services1. Anyone can write a Terraform provider, either as an individual or as part of a community2. HashiCorp maintains some providers, such as the AWS, Azure, and Google Cloud providers3. Cloud providers and infrastructure vendors can also write, maintain, or collaborate on Terraform providers, such as the VMware, Oracle, and Alibaba Cloud providers. Reference =
* 1: Providers - Configuration Language | Terraform | HashiCorp Developer
* 2: Plugin Development - How Terraform Works With Plugins | Terraform | HashiCorp Developer
* 3: Terraform Registry
* : Terraform Registry
Question 26

How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?
Explanation:
This will trigger a run in the Terraform Cloud workspace, which will perform a plan and apply operation on the infrastructure defined by the Terraform configuration files in the VCS repository.
Question 27

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?
Explanation:
This is a secure way to inject sensitive variables into your Terraform run, as they will not be stored in any file or source code repository. You can also use environment variables or variable files with encryption to pass sensitive variables to Terraform.
Question 28

When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
Explanation:
You need to write Terraform configuration files for the existing infrastructure that you want to import into Terraform, otherwise Terraform will not know how to manage it. The configuration files should match the type and name of the resources that you want to import.
Question 29

Variables declared within a module are accessible outside of the module.
Explanation:
Variables declared within a module are only accessible within that module, unless they are explicitly exposed as output values1.
Question 30

Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state files. How can you protect that data?
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.
Question