Practice Free Terraform Associate 004 Exam Online Questions
Which Terraform command checks that your configuration syntax is correct?
- A . terraform validate
- B . terraform init
- C . terraform show
- D . terraform fmt
A
Explanation:
The terraform validate command is used to check that your Terraform configuration files are syntactically valid and internally consistent. It is a useful command for ensuring your Terraform code is error-free before applying any changes to your infrastructure.
What kind of configuration block will create an infrastructure object with settings specified within the block?
- A . provider
- B . state
- C . data
- D . resource
D
Explanation:
This is the kind of configuration block that will create an infrastructure object with settings specified within the block. The other options are not used for creating infrastructure objects, but for configuring providers, accessing state data, or querying data sources.
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.
What is one disadvantage of using dynamic blocks in Terraform?
- 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
D
Explanation:
This is one disadvantage of using dynamic blocks in Terraform, as they can introduce complexity and reduce readability of the configuration. The other options are either advantages or incorrect statements.
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
- A . curl commands manually run from a terminal
- B . A sequence of REST requests you pass to a public cloud API endpoint Most Voted
- C . A script that contains a series of public cloud CLI commands
- D . A series of commands you enter into a public cloud console
C
Explanation:
The concept of infrastructure as code (IaC) is to define and manage infrastructure using code, rather than manual processes or GUI tools. A script that contains a series of public cloud CLI commands is an example of IaC, because it uses code to provision resources into a public cloud. The other options are not examples of IaC, because they involve manual or interactive actions, such as running curl commands, sending REST requests, or entering commands into a console.
Reference = [Introduction to Infrastructure as Code with Terraform] and [Infrastructure as Code]
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.
Which of the following is not a valid string function in Terraform?
- A . chomp
- B . join
- C . slice
- D . split
C
Explanation:
Referencing Terraform Built-in Functions:
✅ chomp: removes trailing newlines
✅ join: combines list into string
✅ split: splits string into list
❌ slice:is nota valid Terraform string function (it’s used in other languages like Python)
Changing the Terraform backend from the default "local" backend to a different one after performing your first terrafom apply is:
- A . Optional
- B . Impossible
- C . Mandatory
- D . Discouraged
D
Explanation:
Changing the Terraform backend after performing the initial terraform apply is technically possible but strongly discouraged. This is because changing backends can lead to complexities in state management, requiring manual intervention such as state migration to ensure consistency. Terraform’s documentation and best practices advise planning the backend configuration carefully before applying Terraform configurations to avoid such changes.
Reference = This guidance is consistent with Terraform’s official documentation, which recommends careful consideration and planning of backend configurations to avoid the need for changes.
What is modified when executing Terraform inrefresh-only mode?
- A . Your Terraform configuration.
- B . Your Terraform plan.
- C . Your state file.
- D . Your cloud infrastructure.
C
Explanation:
Inrefresh-only mode (terraform apply -refresh-only), Terraform updates the state fileto match the actual infrastructure without modifying resources.
A (Terraform configuration)CNot modifiedin refresh-only mode.
B (Terraform plan)CPlan is generated but not modified.
D (Cloud infrastructure)CNot modifiedin refresh-only mode. Official Terraform Documentation
Reference: Refresh-Only Mode
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.
- A . True
- B . False
B
Explanation:
By default, terraform fmt modifies files in place to match Terraform’s canonical formatting. The – check flag is required to only check formatting without making changes.
Analysis of Incorrect Options (Distractors):
A: Incorrect because formatting changes are applied automatically by default. Key Concept:
terraform fmt enforces consistent formatting by rewriting files unless instructed otherwise.
Reference: Terraform Exam Objective C Understand Terraform Basics and CLI
