Practice Free Terraform Associate 004 Exam Online Questions
What functionality do providers offer in Terraform?(Pick 3 correct responses)
- 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.
A,B,D
Explanation:
A ( ✅ Correct)C Providers allow Terraform tointeract with APIsof cloud/on-premises services.
B ( ✅ Correct)C Some Terraform providers can provisionon-premises infrastructure, such as VMware, OpenStack, etc.
C ( ❌ Incorrect)C This describesTerraform Workspaces, not providers.
D ( ✅ Correct)C Terraform providers allow provisioning ofpublic cloud resources(AWS, Azure, GCP, etc.).
E ( ❌ Incorrect)C Enforcing security and compliance policies isnot a direct provider function, but it can be done using Sentinel or other policy-as-code tools.
Official Terraform Documentation
Reference: Terraform Providers
A terraform apply can not _________ infrastructure.
- A . change
- B . destroy
- C . provision
- D . import
D
Explanation:
The terraform import command is used to import existing infrastructure into Terraform’s state. This allows Terraform to manage and destroy the imported infrastructure as part of the configuration. The terraform import command does not modify the configuration, so the imported resources must be manually added to the configuration after the import.
Reference = [Importing Infrastructure]
A terraform apply can not _________ infrastructure.
- A . change
- B . destroy
- C . provision
- D . import
D
Explanation:
The terraform import command is used to import existing infrastructure into Terraform’s state. This allows Terraform to manage and destroy the imported infrastructure as part of the configuration. The terraform import command does not modify the configuration, so the imported resources must be manually added to the configuration after the import.
Reference = [Importing Infrastructure]
Provides a browsable directory
- A . Subfolder within a workspace
- B . Generic git repository
- C . Terraform Cloud private registry
- D . Public Terraform module registry
C
Explanation:
This is the method for sharing Terraform configurations that fulfills the following criteria:
Keeps the configurations confidential within your organization
Supports Terraform’s semantic version constraints
Provides a browsable directory
The Terraform Cloud private registry is a feature of Terraform Cloud that allows you to host and manage your own modules within your organization, and use them in your Terraform configurations with versioning and access control.
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"
B
Explanation:
Terraform modules are referenced by specifying a source location. This location can be a URL or a file path. However, specifying query parameters such as ?version=vl.6.0 directly within the source path is not a valid or supported method for specifying a module version in Terraform. Instead, version constraints are specified using the version argument within the module block, not as part of the source string.
Reference = This clarification is based on Terraform’s official documentation regarding module usage, which outlines the correct methods for specifying module sources and versions.
A module block is shown in the Exhibit space of this page.
When you use a module block to reference a module from the Terraform Registry such as the one in the example, how do you specify version 1.0.0 of the module?
- A . Append ?ref=v1.0.0 argument to the source path.
- B . You cannot. Modules stored on the public Terraform Registry do not support versioning.
- C . Add a version = "1.0.0" attribute to the module block.
- D . Nothing. Modules stored on the public Terraform module Registry always default to version 1.0.0.
C
Explanation:
Module Versioning: To specify a version in a module block for modules in theTerraform Registry, you add the version attribute, e.g., version = "1.0.0".
Terraform Registry Support: The public registrysupports versioningby enabling semantic constraints, allowing users to define specific versions compatible with their infrastructure requirements.
Refer to themodule versioning documentationin Terraform’s official registry guide.
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.
D
Explanation:
Rationale for Correct Answer
A major IaC advantage is declarative desired state: you describe what you want, and the tool figures out the necessary create/update/delete API calls to converge infrastructure to that end state. This reduces manual API orchestration and makes changes repeatable and reviewable.
Analysis of Incorrect Options (Distractors):
A: Incorrect―IaC reduces the need to write individual API calls; that’s the point.
B: Incorrect―IaC tools typically use provider plugins and APIs; efficiency is not about “calling CLI tools.”
C: Incorrect―IaC configurations define desired state; “current state” is discovered via refresh/state, not defined as the goal.
Key Concept: Declarative IaC: define end state, tool determines API actions.
Reference: Terraform Objectives ― Understand Infrastructure as Code (IaC) Concepts; Understand Terraform’s Purpose and Use Cases.
You cannot install third party plugins using terraform init.
- A . True
- B . False
B
Explanation:
You can install third party plugins using terraform init, as long as you specify the plugin directory in your configuration or as a command-line argument. You can also use the terraform providers mirror command to create a local mirror of providers from any source.
A module can always refer to all variables declared in its parent module.
- A . True
- B . False
B
Explanation:
A module cannot always refer to all variables declared in its parent module, as it needs to explicitly declare input variables and assign values to them from the parent module’s arguments. A module cannot access the parent module’s variables directly, unless they are passed as input arguments.
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
B
Explanation:
If you manually destroy infrastructure, Terraform will automatically detect the change and update the state file during the next plan or apply. Terraform compares the current state of the infrastructure with the desired state in the configuration and generates a plan to reconcile the differences. If a resource is missing from the infrastructure but still exists in the state file, Terraform will attempt to recreate it. If a resource is present in the infrastructure but not in the state file, Terraform will ignore it unless you use the terraform import command to bring it under Terraform’s management.
Reference = [Terraform State]
