Which type best represents a collection of unique strings when element order is not significant?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationA set(string) models a collection whose members are strings, whose values are unique, and whose order has no significance. A list preserves an ordered sequence, a map associates keys with string values, and the shown tuple describes a fixed structural shape rather than the required unordered collection.
 A resource block is shown in the Exhibit space of this page. What is the provider for this resource?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationTerraform resource types commonly combine the provider name with the provider-specific resource name. In resource "aws_vpc" "main", the aws prefix identifies the provider and vpc identifies the resource type. main is Terraform's local resource name, while test is an argument value.
terraform init retrieves and caches the configuration for all remote modules.
-
A
-
B
Reveal answer details
Close answer details
Correct answerA
Explanationterraform init prepares the working directory by finding the remote modules declared by the configuration, retrieving their packages, and caching them locally. This initialization allows later Terraform commands to use those module contents without treating every operation as a fresh module installation.
Which of the following is availableonlyinHCP Terraform workspacesandnot in Terraform CLI?
-
A
Dry runs with terraform plan.
-
B
-
C
Using one workspace ' s state as a data source for another.
-
D
Support for multiple cloud providers.
Reveal answer details
Close answer details
Correct answerB
ExplanationHCP Terraform workspaces provide managed storage for workspace variables, including controls for values that must be handled securely. Terraform CLI can receive variables through files, command arguments, or environment variables, but it does not itself provide an equivalent hosted secure variable store. Planning and multi-provider support are available with the CLI.
What is the provider for this resource?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerD
ExplanationIn the given Terraform configuration snippet: resource " aws_vpc " " main " { name = " test " } The provider for the resource aws_vpc is aws. The provider is specified by the prefix of the resource type. In this case, aws_vpc indicates that the resource type vpc is provided by the aws provider. References: Terraform documentation on providers: Terraform Providers
Which of the following is not a benefit of adopting infrastructure as code?
-
A
-
B
A Graphical User Interface
-
C
-
D
Reveal answer details
Close answer details
Correct answerB
ExplanationInfrastructure as code derives its benefits from expressing infrastructure in files that can be versioned, reused, reviewed, and automated. A graphical user interface is an interaction method, not an inherent benefit of adopting code-based infrastructure management. IaC can be used without providing a GUI at all.
All standard backend types support state locking, and remote operations like plan, apply, and destroy.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationBackend capabilities differ, so state locking and remote execution cannot be assumed for every standard backend type. A backend may store state without supplying a locking mechanism, and operations such as plan, apply, and destroy may still execute locally. Because the statement assigns both capabilities to all backends, it is false.
Question 8
Lab simulation
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. Terraform.tfstate
Reveal model answer
Close model answer
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]
ExplanationThe default local state filename is terraform.tfstate. It contains Terraform's representation of the managed infrastructure, including resource metadata and attributes used to compare configuration with recorded state and plan changes. With the default local backend, Terraform keeps this file in the working directory.
You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider?
-
A
-
B
Run terraform init -upgrade.
-
C
Run terraform apply -upgrade.
-
D
Upgrade your version of Terraform.
Reveal answer details
Close answer details
Correct answerB
ExplanationAfter changing the allowed provider version, terraform init -upgrade reinitializes provider dependencies while permitting Terraform to select a newer version that satisfies the configuration's constraints. It then downloads and installs that provider package and updates dependency selections as needed. Refresh and apply do not serve as provider installation upgrade commands.
Question 10
Single choice
You can reference a resource created with for_each using a Splat ( *) expression.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationA resource using for_each produces instances identified by map keys or set members, not a positional sequence suitable for a splat expression. Such an instance is referenced with its key, or its attributes are collected with a for expression. Splat syntax is associated with list-like collections such as instances created by count.
Question 11
Single choice
In a HCP Terraform/Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationIn a version-control workflow, speculative plans are associated with proposed changes before they are merged, such as pull requests. A commit or merge to the tracked branch starts a normal workspace run that can proceed through the workspace's configured run workflow. Therefore, calling the automatically triggered post-commit run speculative is incorrect.
Question 12
Single choice
Which option does not keep secret variable values out of Terraform configuration files?
-
A
Pass the secret values via a -var flag.
-
B
Pass the secret values as environment variables.
-
C
Store the secrets in a shared credentials file.
-
D
Configure the variable as sensitive.
Reveal answer details
Close answer details
Correct answerD
ExplanationMarking a variable as sensitive controls how Terraform redacts that value in normal output; it does not move the value out of the configuration file. If a secret is written in configuration, the sensitive setting does not erase it from that file. Runtime environment variables, a -var argument, or an external credentials file can supply values from outside the configuration.
Question 13
Multiple choice
Which parameters does the import block require? (Pick the 2 correct responses below.)
-
A
-
B
-
C
The target resource address
-
D
Reveal answer details
Close answer details
Correct answersA, C
ExplanationAn import block needs the external resource ID so the provider can identify the existing infrastructure object. It also needs the target resource address that tells Terraform where to bind that object in state. Provider selection can follow the target resource's configuration, while backend settings are unrelated to identifying an imported object.
Question 14
Single choice
terraform plan updates your state file.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
Explanationterraform plan calculates and displays proposed actions, but it does not persist those proposed infrastructure changes as new state. State is updated when an operation such as apply records actual results. This separation allows a plan to be reviewed without treating its proposed values and actions as already completed infrastructure.
Question 15
Single choice
Terraform providers are part of the Terraform core binary.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationProviders are separate plugins rather than components compiled into the Terraform core binary. Terraform core loads the required provider plugins and communicates with them to perform resource-specific operations. This separation allows provider implementations and versions to be selected independently of the core executable.
Question 16
Multiple choice
Where does HashiCorp recommend you store API tokens and other secrets within your team ' s Terraform workspaces? Pick three correct responses below:
-
A
In a plaintext document on a shared drive.
-
B
-
C
In a terraform.tfvars file, checked into your version control system.
-
D
In an environment variable and referenced with TF_VAR_variablename.
-
E
In an HCP Terraform variable, with the sensitive option checked.
Reveal answer details
Close answer details
Correct answersB, D, E
ExplanationHashiCorp Vault is designed to store and control access to secrets centrally. A secret can also be supplied through an environment variable using the TF_VAR_variablename convention, keeping its value outside committed configuration. In HCP Terraform, a workspace variable marked with the sensitive option protects its display. Plaintext shared documents and committed tfvars files expose secret values.
Question 17
Single choice
Which of the following is not a valid string function in Terraform?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationThe slice function operates on a list or tuple by selecting elements between index positions; it is therefore a collection function rather than a string function. By contrast, chomp removes trailing newline characters from a string, join combines string elements, and split divides a string using a separator.
Question 18
Multiple choice
Which two core Terraform workflow steps are used to preview proposed changes and then provision new infrastructure? Choose two correct answers.
-
A
-
B
-
C
-
D
-
E
Reveal answer details
Close answer details
Correct answersA, E
Explanationterraform plan calculates and presents the actions required to move from the current state to the declared configuration. terraform apply then executes those actions to provision the resources. Initialization prepares the working directory, while import adopts existing infrastructure rather than provisioning new infrastructure.
Question 19
Single choice
What does terraform import do?
-
A
Imports existing resources into the state file
-
B
Imports all infrastructure from a given cloud provider
-
C
Imports a new Terraform module
-
D
Imports clean copies of tainted resources
-
E
Reveal answer details
Close answer details
Correct answerA
Explanationterraform import associates an existing remote resource with a resource address in Terraform state. This allows Terraform to begin tracking an object that was created outside the current workflow, provided matching configuration is available for ongoing management. It does not import every object from a provider, download a module, or recreate a tainted resource.
Question 20
Multiple choice
How does the use of Infrastructure as Code (IaC) enhance the reliability of your infrastructure? Pick the two correct responses below.
-
A
Proposed changes can be reviewed before being applied.
-
B
Infrastructure is automatically scaled to meet demand.
-
C
Incorrect configurations cannot be deployed.
-
D
Updates are deployed with zero downtime.
-
E
Configuration drift is reduced with declarative definitions.
Reveal answer details
Close answer details
Correct answersA, E
ExplanationA proposed Infrastructure as Code change can be reviewed before execution, allowing errors and unintended effects to be caught before they alter infrastructure. Declarative definitions also provide a repeatable desired state, reducing configuration drift from ad hoc changes. IaC alone does not guarantee automatic scaling, zero downtime, or that an incorrect configuration can never deploy.
Question 21
Single choice
Module variable assignments are inherited from the parent module and you do not need to explicitly set them.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationEach child module has its own input-variable interface and scope. A parent module passes values through arguments in the child module block; those assignments are not inherited automatically merely because similarly named values exist in the parent. If an input is not explicitly passed, the child must have an applicable default or the input remains required.
Question 22
Single choice
Two configurations of the same provider target different regions, and the second configuration has an alias. How is a resource routed to the second region?
-
A
Explicitly select the aliased provider configuration for the resource.
-
B
Name the resource after the region so Terraform infers the alias.
-
C
Declare the alias and let Terraform match it to resource arguments.
-
D
Put both regions in one default provider configuration.
Reveal answer details
Close answer details
Correct answerA
ExplanationAn alias creates an additional configuration of the same provider, but resources do not select it from their names or arguments automatically. The resource must explicitly reference the aliased provider configuration. Terraform then routes that resource's operations through the configuration for the second region.
Question 23
Single choice
HashiCorp Configuration Language (HCL) supports user-denned functions.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationHCL configurations can call the functions Terraform provides, but HCL does not provide a facility for declaring arbitrary user-defined functions. Repeated expressions can be organized with local values or modules, yet those constructs do not create new callable functions. The statement is therefore false.
Question 24
Single choice
Directly referencing a network resource's exported identifier supplies a subnet argument. What additional effect does this normally have?
-
A
It forces the identifier to be known before planning begins.
-
B
It creates an implicit dependency from the subnet to the network.
-
C
It requires a separate depends_on entry for the same relationship.
-
D
It makes declaration order determine the operations sequence.
Reveal answer details
Close answer details
Correct answerB
ExplanationA reference from the subnet argument to the network's exported identifier creates a data-flow edge in Terraform's dependency graph. Because the subnet needs the network's result, Terraform can order their operations accordingly. A duplicate explicit dependency or reliance on file order is unnecessary.
Question 25
Single choice
Which of these actions will prevent two Terraform runs from changing the same state file at the same time?
-
A
Refresh the state after running Terraform
-
B
Delete the state before running Terraform
-
C
Configure state locking for your state backend
-
D
Run Terraform with parallelism set to 1
Reveal answer details
Close answer details
Correct answerC
ExplanationState locking is the coordination mechanism that prevents concurrent runs from writing the same state. A backend that supports and is configured for locking grants one run exclusive access during the state operation, so another run must wait or stop. Setting parallelism to 1 only limits operations inside one run; it does not coordinate separate runs.
Question 26
Single choice
If a module declares a variable with a default, that variable must also be defined within the module.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationA variable declaration with a default already provides a value when the calling module does not supply one. The caller may override that default, but it does not have to define or pass the variable separately for the module to evaluate. Only an input variable without a default requires a value from an applicable external input source.
Question 27
Single choice
You much initialize your working directory before running terraform validate.
-
A
-
B
Reveal answer details
Close answer details
Correct answerA
ExplanationTerraform validate checks whether a configuration is internally valid in the context of its initialized modules and provider requirements. Running terraform init first prepares those dependencies and the working directory metadata needed for validation. The requirement concerns initialization of the directory, not applying or creating infrastructure.
Question 28
Single choice
What is an advantage of immutable infrastructure?
-
A
In-place infrastructure upgrades
-
B
Quicker infrastructure upgrades
-
C
Automatic infrastructure upgrades
-
D
Less complex infrastructure upgrades
Reveal answer details
Close answer details
Correct answerD
ExplanationImmutable infrastructure replaces a component with one built from the updated definition instead of modifying the existing component in place. This avoids accumulating a unique sequence of manual changes on each instance. Using a consistent replacement process makes infrastructure upgrades less complex and more repeatable.
Question 29
Multiple choice
A module block used in your configuration is shown in the exhibit. You have been asked to update the version of this module from 4.2.1 to 5.0.0. Exhibit: module " compute " { source = " Azure/compute/azurerm " version = " 4.2.1 " } Which two steps must you take to accomplish this?
-
A
Run the terraform init command.
-
B
Run the terraform pull command.
-
C
Update the version argument in the module block.
-
D
Remove the version argument from the module block.
Reveal answer details
Close answer details
Correct answersA, C
ExplanationFirst update the module block's version argument from 4.2.1 to 5.0.0 so the configuration requests the new release. Then run terraform init, which reinitializes the working directory and obtains the module version allowed by the updated constraint. Removing the argument would stop pinning the requested version.
Question 30
Single choice
A data source is shown in the exhibit below. How do you reference the id attribute of this data source?  } }
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerA
ExplanationA data source reference begins with data, followed by its type, local name, and requested attribute. The declaration has type aws_ami and name web, so its ID is referenced as data.aws_ami.web.id. Omitting the data namespace would instead use resource-address syntax.
Question 31
Single choice
It is best practice to store secret data in the same version control repository as your Terraform configuration.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationSecret data should be kept outside the version control repository containing Terraform configuration. Repository history can retain committed values even after a later edit removes them, and repository access may be broader than secret access. External secret storage or protected runtime injection separates credentials from versioned infrastructure code.
Question 32
Single choice
Which is a recommended way to share Terraform state across teams?
-
A
Use a remote state backend.
-
B
No additional configuration is recommended.
-
C
Store the terraform.tfstate file in version control.
-
D
Store the terraform.tfstate file in HashiCorp Vault.
Reveal answer details
Close answer details
Correct answerA
ExplanationA remote state backend gives collaborating teams a shared location for Terraform state instead of distributing separate local copies. Team members can work against the same current state through the configured backend, reducing conflicts caused by manually copying files. Committing terraform.tfstate to version control is not the recommended sharing mechanism.
Question 33
Single choice
Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Cloud automatically and proactively enforce this security control?
-
A
Auditing cloud storage buckets with a vulnerability scanning tool
-
B
By adding variables to each Terraform Cloud workspace to ensure these settings are always enabled
-
C
With an S3 module with proper settings for buckets
-
D
With a Sentinel policy, which runs before every apply
Reveal answer details
Close answer details
Correct answerD
ExplanationA Sentinel policy expresses the required privacy and encryption rules as policy checks evaluated before each apply. This places enforcement in the Terraform Cloud run workflow, allowing a noncompliant proposal to be stopped before resource changes are executed. A scanning tool audits separately, while variables or a module alone do not centrally enforce every proposed bucket.
Question 34
Single choice
Which task does terraform init not perform?
-
A
Validates all required variables are present
-
B
Sources any modules and copies the configuration locally
-
C
-
D
Sources all providers used in the configuration and downloads them
Reveal answer details
Close answer details
Correct answerA
Explanationterraform init prepares a working directory by initializing its backend and obtaining the modules and providers required by the configuration. Its job is not to verify that every required input variable has been assigned a value. Missing required values become relevant when Terraform evaluates an operation that needs those inputs, rather than during basic initialization.
Question 35
Single choice
Why is it important to treat your Terraform state file as sensitive?
-
A
It can contain information such as resource passwords and keys.
-
B
It stores all environment variables from the machine that created it.
-
C
It can be manually edited to change deployed resources.
-
D
It contains personal information about the last user to update it.
Reveal answer details
Close answer details
Correct answerA
ExplanationTerraform state can retain resource attributes returned by providers, including sensitive values such as passwords and keys. Those values may remain present even when Terraform suppresses them from ordinary command output. Anyone who can read the state could therefore gain access to credentials, which is why state storage and access must be secured.
Question 36
Multiple choice
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
-
A
You can restrict specific resource configurations, such as disallowing the use of CIDR=0.0.0.0/0.
-
B
You can check out and check in cloud access keys
-
C
Sentinel Policies can be written in HashiCorp Configuration Language (HCL)
-
D
Policy-as-code can enforce security best practices
-
E
You can enforce a list of approved AWS AMIs
Reveal answer details
Close answer details
Correct answersA, D, E
ExplanationSentinel policy-as-code can examine proposed resource configurations and reject values that violate policy, such as an unrestricted CIDR of 0.0.0.0/0. This enables consistent enforcement of security best practices before changes proceed. A policy can also require an approved list of AWS AMIs, preventing unapproved images from being used.
Question 37
Single choice
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
-
C
Review /var/log/terraform.log for error messages.
-
D
Review syslog for Terraform error messages.
Reveal answer details
Close answer details
Correct answerB
ExplanationSetting TF_LOG=DEBUG enables detailed Terraform diagnostic logging for the failing operation. Those messages provide more context about backend requests and the reported 403 access denial, which helps identify the root cause. Terraform does not inherently place its errors in the listed operating-system log locations, and provider authentication is not performed by terraform login.
Question 38
Single choice
What does state looking accomplish?
-
A
Prevent accidental Prevent accident deletion of the state file
-
B
Blocks Terraform commands from modifying, the state file
-
C
Copies the state file from memory to disk
-
D
Encrypts any credentials stored within the state file
Reveal answer details
Close answer details
Correct answerB
ExplanationState locking prevents another Terraform operation from writing to the same state while a state-modifying operation is in progress. This blocks concurrent commands from making conflicting modifications and reduces the risk of inconsistent state. It does not encrypt credentials, copy memory to disk, or guarantee protection from file deletion.
Question 39
Single choice
You ' re writing a Terraform configuration that needs to read input from a local file called id_rsa.pub. Which built-in Terraform function can you use to import the file ' s contents as a string?
-
A
fileset( " id_rsa.pub " )
-
B
-
C
filebase64( " id_rsa.pub " )
-
D
templatefile( " id_rsa.pub " )
Reveal answer details
Close answer details
Correct answerB
ExplanationThe file("id_rsa.pub") function reads the named local file and returns its contents as a string, which directly meets the requirement. fileset identifies matching filenames, while filebase64 returns an encoded representation. templatefile is for rendering a file as a template with supplied values.
Question 40
Single choice
You can configure Terraform to log to a file using the TF_LOG environment variable.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationTF_LOG controls whether Terraform logging is enabled and which verbosity level is used; it does not select a log file. File output requires a separate destination setting, TF_LOG_PATH, while TF_LOG remains enabled. Therefore, setting TF_LOG alone cannot configure logging to a file.
Question 41
Single choice
Does terraform init create an example main.tf file in the current directory?
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
Explanationterraform init prepares an existing working directory for Terraform operations. It initializes the configured backend and obtains the providers and modules required by configuration already present in that directory. It does not scaffold an example main.tf file, so configuration must be created or supplied separately.
Question 42
Single choice
terraform init creates an example main.tf file in the current directory.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
Explanationterraform init prepares an existing working directory for Terraform operations. It initializes the configured backend and installs required providers and referenced modules, but it does not author an example main.tf configuration. Configuration files must already exist or be created separately, so the statement is false.
Question 43
Single choice
Which command lets you experiment with terraform expressions?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerA
Explanationterraform console opens an interactive environment that evaluates Terraform expressions in the context of a configuration. It is useful for testing references, functions, and value transformations before placing them into resource arguments. terraform validate checks configuration validity, while the other commands do not provide this expression-evaluation session.
Question 44
Single choice
Which argument can you set on a module block to prevent Terraform from updating the module's configuration during an init or get operation?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerA
ExplanationThe module block's version argument constrains which published module release Terraform may select. Pinning it to an exact version prevents a later init or get operation from selecting a different release unless the constraint is changed. The source identifies the module location rather than its allowed release.
Question 45
Single choice
Which type of information does the Terraform Registry provide about the modules it hosts?
-
A
-
B
-
C
Optional input variables and default values
-
D
All of these are provided
Reveal answer details
Close answer details
Correct answerD
ExplanationThe Terraform Registry documents a hosted module's interface. That interface includes required input variables, optional input variables with their default values, and the outputs exposed by the module. Together, these details tell a caller what must be supplied, what can be omitted, and what values can be consumed after use.
Question 46
Single choice
Exhibit: resource " azurerm_linux_web_app " " app " { name = " example-app " resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location service_plan_id = azurerm_service_plan.plan.id identity { type = " UserAssigned " identity_ids = [azurerm_user_assigned_identity.app.id] } } resource " azurerm_role_assignment " " kv_access " { scope = azurerm_key_vault.kv.id role_definition_name = " Key Vault Secrets User " principal_id = azurerm_user_assigned_identity.app.principal_id } Two resource blocks are shown: azurerm_linux_web_app and azurerm_role_assignment. When provisioned, the web app will use the role assignment during creation, so the role assignment must be created first. How do you ensure the azurerm_role_assignment resource is created first?
-
A
Add a depends_on argument to the azurerm_linux_web_app.
-
B
Add a create_before_destroy argument to the azurerm_role_assignment.
-
C
Change the order of the azurerm_linux_web_app and azurerm_role_assignment blocks.
-
D
Add a count argument to both resources.
Reveal answer details
Close answer details
Correct answerA
ExplanationAdd depends_on to azurerm_linux_web_app.app and reference azurerm_role_assignment.kv_access. This creates an explicit dependency edge, so Terraform completes the role assignment before creating the web app. Reordering blocks does not control Terraform's dependency graph, and create_before_destroy addresses replacement behavior.
Question 47
Single choice
You want to know from which paths Terraform is loading providers referenced in your Terraform configuration (* files). You need to enable additional logging messages to find this out. Which of the following would achieve this?
-
A
Set verbose for each provider in your Terraform configuration
-
B
Set the environment variable TF_LOG_TRACE
-
C
Set the environment variable TF_LOG_PATH
-
D
Set the environment variable TF_log_TRACE
Reveal answer details
Close answer details
Correct answerB
ExplanationThis will enable additional logging messages to find out from which paths Terraform is loading providers referenced in your Terraform configuration files, as it will set the log level to TRACE, which is the most verbose and detailed level.
Question 48
Single choice
What kind of configuration block will create an infrastructure object with settings specified within the block?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerD
ExplanationA resource block declares an infrastructure object that Terraform should create and manage using the settings inside that block. A provider block configures the integration used to perform operations, while a data block reads existing information. State is Terraform's record of managed objects, not a configuration block that creates one.
Question 49
Single choice
What type of block is used to construct a collection of nested configuration blocks?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerA
ExplanationA dynamic block generates repeated nested configuration blocks from a collection. Its iteration expression supplies the elements, and its content section describes the nested block body produced for each element. for_each can participate in that construction, but it is a meta-argument or expression rather than the block type requested. The applicable block type is Dynamic.
Question 50
Single choice
When do changes invoked by terraform apply take effect?
-
A
After Terraform has updated the state file
-
B
Once the resource provider has fulfilled the request
-
C
-
D
None of the above are correct
Reveal answer details
Close answer details
Correct answerB
ExplanationTerraform sends the requested operation through the resource provider, which communicates with the target service. The infrastructure change takes effect when that provider has fulfilled the request. Updating the state file records the resulting managed state, but the state update is not what causes the external resource operation itself.
Question 51
Single choice
You've enabled DEBUG-level logging for Terraform, and you'd like to send the log data to a file. Which action should you take?
-
A
Set the TF_LOG_PATH environment variable.
-
B
Update the Terraform CLI configuration file.
-
C
Add a path argument to the terraform block.
-
D
Run the terraform output command.
Reveal answer details
Close answer details
Correct answerA
ExplanationAfter DEBUG logging is enabled, TF_LOG_PATH specifies the file to which Terraform appends its log output. Setting this environment variable directs the generated diagnostic records away from being only terminal output and into the chosen file. The output command reads declared outputs and does not configure diagnostic logging.
Question 52
Single choice
You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account already contains 15 virtual machines (VM). You develop a Terraform configuration containing one VM. perform terraform apply, and see that your VM was created successfully. What should you do to delete the newly-created VM with Terraform?
-
A
The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM.
-
B
Delete the Terraform state file and execute terraform apply.
-
C
The Terraform state file only contains the one new VM. Execute terraform destroy.
-
D
Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state file.
Reveal answer details
Close answer details
Correct answerC
ExplanationTerraform does not automatically add every resource in a cloud account to its state. This configuration created and tracks only the one new VM; the 15 pre-existing VMs remain unmanaged by it. Running terraform destroy uses that state relationship to delete the one managed VM without selecting from all 16 account resources.
Question 53
Multiple choice
Which of these are features of HCP Terraform/Terraform Cloud? Pick the 2 correct responses below.
-
A
Automated infrastructure deployment visualization.
-
B
A web-based user interface (UI).
-
C
Automatic backups of configuration and state.
-
D
Reveal answer details
Close answer details
Correct answersB, D
ExplanationHCP Terraform and Terraform Cloud provide a web-based user interface for viewing and managing workspace activity without relying solely on local CLI interaction. They also keep workspace state remotely, giving runs a shared state location outside an individual operator's machine. These are two distinct platform capabilities.
Question 54
Single choice
_______backends support state locking.
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationState locking depends on the capabilities implemented by the selected backend. Backends that support locking can prevent concurrent state-changing operations, while others cannot provide that coordination. Therefore locking is supported by some backends, not universally by all backends and not exclusively by the local backend.
Question 55
Single choice
You want to create a string that combines a generated random_id and a variable and reuse that string several times in your configuration. What is the simplest correct way to implement this without repeating the random_id and variable?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationA local value can assign a name to the expression that combines the generated random_id with the input variable. Other expressions can then reference that local repeatedly, so the combination is written and maintained once. A module is unnecessary for this small internal expression, and an output is intended to expose a value.
Question 56
Single choice
What command can you run to generateDOT (Graphviz)formatted data to visualize Terraform dependencies?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerB
Explanationterraform graph emits a representation of Terraform's dependency graph in DOT format. That output can be passed to Graphviz tooling to render relationships among resources and other configuration objects. The other commands refresh state, display outputs, or present configuration and state data rather than generating dependency graph data.
Question 57
Single choice
Several environments need separate runs and state, while related environments should share an organizational access boundary. How should HCP Terraform organize them?
-
A
Use one project as the state container for every run.
-
B
Group separate workspaces inside a project.
-
C
Replace HCP workspaces with Terraform CLI workspaces.
-
D
Put every environment in one workspace and one state.
Reveal answer details
Close answer details
Correct answerB
ExplanationEach environment should use a separate HCP Terraform workspace so its runs and state remain isolated from the others. Related workspaces can then be grouped inside one project, which supplies the requested organizational boundary for managing access without combining every environment into one state.
Question 58
Single choice
Why is it considered important to treat your Terraform state file as sensitive?
-
A
It can contain information such as resource passwords and keys.
-
B
It stores all environment variables from the machine that created it.
-
C
It can be manually edited to change the deployed resources.
-
D
It contains personal information about the last user to update it.
Reveal answer details
Close answer details
Correct answerA
ExplanationTerraform state may contain resource attributes returned by providers, including sensitive values such as passwords or keys. Anyone who can read the state could therefore gain access to credentials even when the configuration does not display them. State should consequently receive access controls and storage protections appropriate for secret-bearing data.
Question 59
Single choice
When a check block's assertion fails, Terraform blocks the current operation from executing.
-
A
-
B
Reveal answer details
Close answer details
Correct answerB
ExplanationA failed assertion in a check block reports a warning about the condition but does not block the current Terraform operation from executing. Check blocks are intended to evaluate and report infrastructure conditions without acting as mandatory execution gates. Consequently, treating every failed check assertion as an operation-stopping error makes the statement false.
Question 60
Single choice
When does Sentinel enforce policy logic during a Terraform Cloud run?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Correct answerC
ExplanationSentinel evaluates policy after Terraform has produced information about the proposed changes but before those changes are applied. This placement lets policy logic inspect the run and prevent a noncompliant plan from reaching the apply phase. Enforcement after apply would occur too late to block the infrastructure modification.
|