Practice Free Terraform Associate 004 Exam Online Questions
Which parameters does terraform import require? Choose two correct answers.
- A . Provider
- B . Resource ID
- C . Resource address
- D . Path
B,C
Explanation:
These are the parameters that terraform import requires, as they allow Terraform to identify the existing resource that you want to import into your state file, and match it with the corresponding configuration block in your files.
When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
- A . You can import infrastructure without corresponding Terraform code
- B . Terraform will generate the corresponding configuration files for you
- C . Before you run terraform Import
- D . After you run terraform import
C
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.
One remote backend configuration always maps to a single remote workspace.
- A . True
- B . False
A
Explanation:
The remote backend can work with either a single remote Terraform Cloud workspace, or with multiple similarly-named remote workspaces (like networking-dev and networking-prod). The workspaces block of the backend configuration determines which mode it uses. To use a single remote Terraform Cloud workspace, set workspaces.name to the remote workspace’s full name (like networking-prod). To use multiple remote workspaces, set workspaces.prefix to a prefix used in all of the desired remote workspace names.
For example, set prefix = “networking-” to use Terraform cloud workspaces with names like networking-dev and networking-prod. This is helpful when mapping multiple Terraform CLI workspaces used in a single Terraform configuration to multiple Terraform Cloud workspaces3. However, one remote backend configuration always maps to a single remote workspace, either by name or by prefix. You cannot use both name and prefix in the same backend configuration, or omit both. Doing so will result in a configuration error3.
Reference = [Backend Type: remote]3
Which of the following module source paths does not specify a remote module?
- A . Source = “module/consul’’
- B . Source = ‘’githhub.comicrop/example’’
- C . Source =’’[email protected]:hasicrop/example.git’’
- D . Source = ‘’hasicrop/consul/aws’’
A
Explanation:
The module source path that does not specify a remote module is source = "module/consul". This specifies a local module, which is a module that is stored in a subdirectory of the current working directory. The other options are all examples of remote modules, which are modules that are stored outside of the current working directory and can be accessed by various protocols, such as Git, HTTP, or the Terraform Registry. Remote modules are useful for sharing and reusing code across different configurations and environments.
Reference = [Module Sources], [Local Paths], [Terraform Registry], [Generic Git Repository], [GitHub]
What is the Terraform style convention for indenting a nesting level compared to the one above it?
- A . With two spaces.
- B . With four spaces.
- C . With three spaces.
- D . With a tab.
A
Explanation:
Terraform’s Indentation Standards: Terraform’s style convention usestwo spaces per nesting levelfor readability, helping to maintain uniform code across teams.
Configuration Files: Consistent indentation is crucial for Terraform’s HCL syntax, as it improves readability and avoids parsing issues.
More details are available in theTerraform configuration style guide.
terraform plan updates your state file.
- A . True
- B . False
B
Explanation:
The terraform plan command does not update the state file. Instead, it reads the current state and the configuration files to determine what changes would be made to bring the real-world infrastructure into the desired state defined in the configuration. The plan operation is a read-only operation and does not modify the state or the infrastructure. It is the terraform apply command that actually applies changes and updates the state file.
Reference = Terraform’s official guidelines and documentation clarify the purpose of the terraform plan command, highlighting its role in preparing and showing an execution plan without making any changes to the actual state or infrastructure.
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.
D
Explanation:
Rationale for Correct Answer (D):
terraform state list shows all resources currently managed by Terraform. terraform state show <resource> provides detailed attributes, including the VM ID. This lets you match the Terraform-
managed instance with the actual infrastructure.
Analysis of Incorrect Options:
A: Importing is not needed since one VM is already in state.
B: terraform apply doesn’t show which VM ID is managed, it only refreshes attributes.
C: Removing state entries is destructive and may lead to losing state data unnecessarily. Key Concept:
The state file is Terraform’s source of truth for which resources it manages.
Reference: Terraform Exam Objective C Implement and Maintain State.
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
A
Explanation:
These are some of the ways that a ticket-based system can slow down infrastructure provisioning and limit the ability to scale, as they introduce delays, bottlenecks, and manual interventions in the process of creating and modifying infrastructure.
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
- 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.
B
Explanation:
The error messageindicates an authentication issue (403 – Access Denied), which requiresdebugging Terraform logs.
Setting TF_LOG=DEBUG enablesdetailed logs, providing insights into API requests, state loading, and authentication errors.
Terraformdoes not log errors in /var/log/terraform.log or syslog, making optionsC and D incorrect.
A (terraform login)is only relevant forTerraform Cloud, but this error appears to be related toprovider authentication.
Official Terraform Documentation
Reference: Debugging Terraform
Which command add existing resources into Terraform state?
- A . Terraform init
- B . Terraform plan
- C . Terraform refresh
- D . Terraform import
- E . All of these
D
Explanation:
This is the command that can add existing resources into Terraform state, by matching them with the corresponding configuration blocks in your files.
