Courseiva

HashiCorp Certified: Terraform Authoring and Operations Professional (AWS provider) (AWS provider) (AWS provider) — Questions 76150

193 questions total · 3pages · All types, answers revealed

Page 1

Page 2 of 3

Page 3
76
MCQhard

When using 'terraform state mv', what is the impact on the collaboration workflow?

A.It changes the state file, which affects subsequent runs
B.It is only possible in local state
C.It requires all team members to re-run init
D.It automatically updates the git repository
AnswerA

State modification changes the mapping of resources in the remote backend.

Why this answer

Modifying the state file manually requires careful coordination to avoid conflicts with other team members' operations.

77
MCQeasy

Which type of Sentinel policy is used to block a run without possibility of override?

A.Advisory.
B.Policy-Override.
C.Soft-mandatory.
D.Hard-mandatory.
AnswerD

Hard-mandatory policies cannot be overridden.

Why this answer

Hard-mandatory policies require the policy to pass before the run can proceed; they cannot be overridden.

78
MCQmedium

Which of these is a valid use case for a dynamic block?

A.Defining nested repeatable blocks
B.Conditional module inclusion
C.Changing the provider configuration dynamically
D.Defining multiple separate resources
AnswerA

Dynamic blocks are designed for nested, repeatable configuration blocks.

Why this answer

Dynamic blocks are specifically intended to generate nested, repeatable blocks within a resource, such as 'ingress' rules in a security group or 'tags' in an instance.

79
MCQhard

If you want to use a provider that is not published in the Terraform Registry, how do you install it?

A.Use a filesystem mirror in the .terraformrc file.
B.You cannot use private providers.
C.Rename the file to provider.tf.
D.Copy it to the root of the project.
AnswerA

Filesystem mirrors allow local development or air-gapped installation.

Why this answer

Local provider mirrors can be configured by placing the binary in specific directory structures and using a CLI configuration file.

80
MCQmedium

You need to manage resources in two different AWS regions using the same provider configuration. How do you achieve this?

A.Define the region twice in a single provider block.
B.Define two separate aws providers in the same file without aliases.
C.Create two separate Terraform projects.
D.Use an alias in the provider block and reference it in the resource using the provider meta-argument.
AnswerD

The provider meta-argument links a resource to a specific aliased provider instance.

Why this answer

Using alias in the provider block allows you to define multiple configurations for the same provider.

81
Multi-Selecthard

Which TWO of the following statements are correct regarding 'for_each' and state?

Select 2 answers
A.for_each creates stable identifiers based on keys
B.count is preferred for all resource types
C.count creates stable identifiers based on keys
D.for_each is preferred over count for map-based configurations
E.for_each is only available for cloud resources
AnswersA, D

Using keys makes resource identity stable.

Why this answer

for_each uses keys which provides stable identities, whereas count uses indices which can cause resource drift if lists change.

82
MCQhard

How can you view the detailed breakdown of cost estimates for a specific Terraform plan?

A.Run the 'terraform show' command on the state file.
B.Check the cloud provider's billing dashboard.
C.Use the Sentinel CLI tool.
D.Open the run page in the HCP Terraform UI.
AnswerD

The UI provides the interface to view cost estimation data.

Why this answer

The run details page in the HCP Terraform UI displays the cost estimation summary, which can be expanded for details.

83
Multi-Selecthard

Which THREE items should be included in a well-documented Terraform module?

Select 3 answers
A.A list of all possible provider configurations.
B.Clear documentation for each output.
C.A description for each input variable.
D.The raw state file of the module's resources.
E.An example of how to call the module.
AnswersB, C, E

Output documentation clarifies what data is exposed.

Why this answer

Documentation should cover how to use the module, its inputs, and its outputs.

84
MCQmedium

You have a team-based collaboration project. Where should you store sensitive credentials like AWS secret keys so they are not hardcoded in your Terraform files?

A.In environment variables marked as 'sensitive'
B.In a .tfvars file
C.In a version-controlled .env file
D.In the state file
AnswerA

Sensitive workspace variables are encrypted at rest and masked in logs.

Why this answer

HCP Terraform variables marked as 'sensitive' are stored securely and never displayed in the UI.

85
Multi-Selecthard

Which are characteristics of the Terraform Plugin SDK? (Select TWO)

Select 2 answers
A.It replaces the Terraform CLI.
B.It manages the Terraform state lock.
C.It compiles HCL to Go code.
D.It provides a way to define schema for resources.
E.It handles resource lifecycle methods (Create, Read, Update, Delete).
AnswersD, E

Core function of the SDK.

Why this answer

It handles the communication between Terraform and the provider binary, and it provides helper functions to define resources.

86
MCQeasy

Which meta-argument is best for deploying resources that are strictly dependent on the number of items in a configuration?

A.count
B.for_each
C.provider
D.dynamic
AnswerA

count is the primary meta-argument for simple integer-based replication.

Why this answer

count is the simplest meta-argument for simple, index-based resource replication where individual resource identity is not critical.

87
Multi-Selecthard

Which TWO of the following are requirements when using a 'dynamic' block?

Select 2 answers
A.A content block
B.A count argument
C.A for_each argument
D.A provider argument
E.An iterator argument
AnswersA, C

Required to define the content of the generated block.

Why this answer

A dynamic block requires a 'for_each' argument to define the iteration, and a 'content' block to define the nested structure.

88
MCQmedium

You need to ensure that an AWS Auto Scaling Group maintains capacity during a configuration change that requires a new launch template. Which lifecycle meta-argument should you use?

A.replace_triggered_by
B.ignore_changes
C.create_before_destroy = true
D.prevent_destroy
AnswerC

This enables the desired behavior for zero-downtime updates.

Why this answer

The create_before_destroy meta-argument ensures that the new resource is created before the old one is destroyed, preventing downtime during replacement.

89
MCQeasy

What happens if a Sentinel policy results in an 'advisory' output?

A.The plan is marked as failed.
B.The run logs display a warning, but the process continues.
C.The policy is treated as a hard-mandatory failure.
D.The run is paused for manual intervention.
AnswerB

Advisory policies are for non-blocking feedback.

Why this answer

Advisory policies provide information or warnings in the run logs but do not block the execution.

90
MCQhard

When writing a custom provider, what is the 'Schema' used for?

A.To define the attributes of resources.
B.To define the cloud service billing.
C.To define the provider's icon.
D.To store state.
AnswerA

Schemas define the fields, types, and requirements.

Why this answer

The schema defines the data structure, types, and constraints for resources and data sources.

91
MCQhard

Which HCP Terraform feature allows you to manage infrastructure across multiple cloud accounts using a single organization?

A.Shared modules
B.Projects
C.Provider aliases
D.Remote execution
AnswerB

Projects allow grouping of workspaces for cross-account organization.

Why this answer

Organization structure in HCP Terraform supports centralized management of projects and workspaces across various cloud accounts.

92
MCQmedium

When using for_each on a resource, how do you access the value of the current iteration inside the resource configuration?

A.each.value
B.each.key
C.item.value
D.count.index
AnswerA

each.value provides the current element from the map or set.

Why this answer

The 'each.value' object is the standard way to access the value in the collection currently being processed by for_each.

93
MCQmedium

A resource has an attribute 'tags' that is managed by an external script. You want Terraform to ignore any changes made to 'tags' after the initial creation. How should you configure the 'lifecycle' block?

A.ignore_changes = [tags]
B.lifecycle { tags = ignore }
C.prevent_destroy = [tags]
D.ignore_changes = [all]
AnswerA

This correctly targets the tags attribute for exclusion.

Why this answer

The ignore_changes meta-argument allows you to specify a list of attributes that Terraform should skip during the refresh and plan phases.

94
MCQeasy

You are creating a security group in AWS and need to define multiple ingress rules based on a list of port numbers. Which meta-argument is most appropriate to use to create one resource instance per port?

A.instance_count
B.count
C.dynamic
D.for_each
AnswerD

for_each is the standard approach for creating multiple resource instances from a collection of values.

Why this answer

The count meta-argument creates multiple instances based on an integer, while for_each is designed for sets or maps, making it the idiomatic choice for collections like lists of port numbers.

95
MCQmedium

You are iterating over a map using for_each. You need to access the key of the current map element. Which object do you use?

A.var.key
B.each.key
C.count.key
D.each.value
AnswerB

each.key is the correct reference for the map index.

Why this answer

each.key provides the key of the map entry currently being processed during a for_each iteration.

96
MCQeasy

What happens if two team members try to apply changes to the same workspace in HCP Terraform simultaneously?

A.The state file will be corrupted
B.The latest one wins
C.Both runs will fail
D.The second run is queued
AnswerD

HCP Terraform automatically manages concurrency via queuing.

Why this answer

HCP Terraform serializes runs; the second run will be queued until the first completes.

97
Multi-Selecthard

Which THREE factors influence the choice of using an HCP Terraform Agent?

Select 3 answers
A.Need for private network connectivity
B.To increase the speed of the provider download
C.Compliance requirements for data locality
D.The need to access internal APIs
E.To remove the need for a VCS
AnswersA, C, D

Agents bridge the private network to HCP Terraform.

Why this answer

Agents are used for private network connectivity, compliance requirements, and accessing resources that don't allow public internet access.

98
MCQhard

If a module has a required variable but you do not provide it in the calling configuration, what happens?

A.Terraform uses 'null' for the value.
B.Terraform uses the variable value from the previous state.
C.Terraform fails with an error during the planning phase.
D.Terraform automatically sets the value to an empty string.
AnswerC

Missing required variables cause immediate validation errors.

Why this answer

Terraform will stop and prompt the user for the missing value during the plan or apply phase if it is not provided via command line or tfvars.

99
Multi-Selectmedium

Which TWO features help maintain consistency across multiple workspaces?

Select 2 answers
A.Unique state files for every module
B.Using local execution only
C.Manual copy-pasting of code
D.Shared modules
E.Variable sets
AnswersD, E

Promotes reusable code across workspaces.

Why this answer

Shared modules and variable sets ensure that configurations and inputs remain consistent across teams and workspaces.

100
MCQmedium

When configuring team permissions, what does the 'Workspace: Settings' permission allow?

A.Viewing plan and apply logs only.
B.Triggering runs manually.
C.Modifying workspace settings like variable sets and execution modes.
D.Deleting the workspace.
AnswerC

Settings permission specifically grants access to configure the workspace environment.

Why this answer

The 'Settings' permission allows users to modify workspace configurations, including variable sets and notification settings.

101
Multi-Selecteasy

Which THREE of the following attributes are available to a Sentinel policy via the 'tfrun' import?

Select 3 answers
A.User who triggered the run.
B.The provider source code.
C.The raw state file contents.
D.Workspace name.
E.Organization name.
AnswersA, D, E

The policy knows the actor.

Why this answer

The 'tfrun' import provides access to metadata about the current run, including the workspace, the user, and the organization.

102
MCQeasy

When using Cost Estimation in HCP Terraform, which of the following is true?

A.It calculates costs based on real-time AWS billing API calls.
B.It applies to all resources, including custom providers.
C.It requires the Terraform provider to support the cost estimation feature.
D.It only works for paid HCP Terraform tiers.
AnswerC

Only providers with specific cost metadata support this feature.

Why this answer

HCP Terraform uses the current plan to calculate cost impact against the existing state.

103
Multi-Selectmedium

Which THREE actions occur when you execute a Terraform run in HCP Terraform?

Select 3 answers
A.Immediate infrastructure destruction
B.Policy evaluation
C.Manual approval
D.Plan generation
E.Local environment cleanup
AnswersB, C, D

Sentinel/OPA policies are evaluated against the plan.

Why this answer

The process involves plan generation, policy evaluation, and then awaiting approval before applying.

104
MCQhard

How can you restrict the ability of team members to delete workspaces?

A.Set the workspace status to 'Locked'.
B.Change the workspace execution mode to local.
C.Remove the 'Delete' permission from the team's project-level permissions.
D.Enable 'Prevent Destroy' in Terraform code.
AnswerC

Project-level permissions allow managing workspace lifecycles.

Why this answer

RBAC in HCP Terraform is granular. You must ensure users do not have the 'Admin' or 'Delete' permissions on the specific workspace.

105
Multi-Selecthard

Which TWO of the following are valid ways to pass a provider configuration to a child module?

Select 2 answers
A.Defining the provider inside the module's 'main.tf'.
B.Using the 'providers' meta-argument inside the module block.
C.Passing the provider as a string input variable.
D.Using a global variable for provider credentials.
E.Inheritance from the root module's provider configuration.
AnswersB, E

Explicit mapping is needed for non-default provider instances.

Why this answer

Providers are either inherited from the root or passed explicitly using the 'providers' map in the module block.

106
Multi-Selecthard

Which TWO actions can be taken to resolve issues where a resource must be replaced, but 'prevent_destroy' is enabled?

Select 2 answers
A.Use 'terraform apply -auto-approve'.
B.Run 'terraform state rm' to remove the resource from state and re-import.
C.Use 'terraform refresh' to update the constraint.
D.Remove the prevent_destroy block from the configuration.
E.Set the prevent_destroy argument to false in the CLI.
AnswersB, D

This removes the resource and its associated constraints.

Why this answer

You must either remove the meta-argument from the code or use the state management to remove the resource constraint before re-applying.

107
MCQeasy

Which of the following is an advantage of using HCP Terraform over local state for team collaboration?

A.It provides state locking and run history
B.It converts HCL to JSON
C.It eliminates the need for AWS providers
D.It is always free
AnswerA

These are core benefits of remote backend management.

Why this answer

HCP Terraform provides centralized state management, locking, and a history of runs, which are critical for teams.

108
MCQeasy

Which of the following is an advantage of using Variable Sets?

A.They centralize variable management to avoid duplication across workspaces.
B.They allow for secret rotation in AWS.
C.They automatically run Terraform plans.
D.They provide encryption for state files.
AnswerA

Centralization is the primary purpose of Variable Sets.

Why this answer

Variable Sets avoid duplication by allowing you to define a set of variables once and reuse them across multiple workspaces.

109
MCQmedium

You are using HCP Terraform agents. Why would you choose to use an agent instead of the public HCP Terraform execution environment?

A.To increase execution speed
B.To access resources in a private network
C.To bypass OPA policies
D.To avoid paying for HCP Terraform
AnswerB

Private network access is the primary use case for agents.

Why this answer

Agents allow Terraform to run in a private network, accessing resources that are not reachable from the public internet.

110
MCQeasy

Which of the following is a primary benefit of using a Private Module Registry?

A.It encrypts all Terraform state files.
B.It allows central management and version control of reusable modules.
C.It forces all workspaces to use the same module versions.
D.It automatically generates cost estimates for all modules.
AnswerB

This is the core value proposition of the Private Module Registry.

Why this answer

The Private Module Registry allows organizations to share verified, reusable infrastructure code internally.

111
MCQhard

When using 'replace_triggered_by', what happens if the referenced resource is deleted?

A.The resource is destroyed as well.
B.The resource is kept as is.
C.The plan fails because the dependency cannot be evaluated.
D.The trigger is ignored.
AnswerC

Terraform requires the referenced resource to exist.

Why this answer

If the referenced resource is deleted, the expression for replace_triggered_by becomes invalid, and Terraform will return an error during the plan phase.

112
MCQeasy

Where are lifecycle meta-arguments placed within a Terraform configuration?

A.At the root of the configuration file.
B.Inside the resource block, within a 'lifecycle' block.
C.Inside the module block.
D.Inside the provider block.
AnswerB

This is the correct location.

Why this answer

Lifecycle meta-arguments must be placed inside a 'lifecycle' block within the resource block.

113
MCQeasy

In HCP Terraform, you want to allow team members to see runs but prevent them from approving plans. Which team permission set should you assign?

A.Write
B.Admin
C.Read
D.Cost Estimation
AnswerC

Read only allows viewing information.

Why this answer

The 'read' permission allows viewing runs and state without modification capabilities.

114
MCQeasy

Where can you view the historical state versions in HCP Terraform?

A.The Variables tab
B.The Runs tab
C.The States tab
D.The Settings tab
AnswerC

This tab lists all previous state versions.

Why this answer

The 'States' tab within a specific workspace shows the full history of state versions.

115
Multi-Selectmedium

Which THREE of the following can be managed using team permissions in HCP Terraform?

Select 3 answers
A.Project visibility.
B.Global IP firewalling.
C.Workspace access.
D.Organization billing limits.
E.Module Registry access.
AnswersA, C, E

Permissions control who can see projects.

Why this answer

Permissions control access to workspaces, projects, and the registry.

116
MCQmedium

You need to ensure that a resource is always recreated if an associated data source value changes. Which meta-argument supports this?

A.create_before_destroy
B.replace_triggered_by
C.lifecycle_hooks
D.prevent_destroy
AnswerB

This is the correct meta-argument for triggering replacement.

Why this answer

The replace_triggered_by meta-argument is specifically designed to force replacement when other resources or data sources change.

117
MCQmedium

What is the purpose of the 'terraform state refresh' command?

A.To delete orphaned resources.
B.To update the state file with current real-world resource attributes.
C.To apply changes to the cloud provider.
D.To upgrade the Terraform version.
AnswerB

This is the purpose of refresh.

Why this answer

This command reconciles the state file with the actual infrastructure in the real world to detect drift.

118
MCQeasy

Which file is automatically generated to lock provider versions and their checksums?

A.terraform.tfstate
B.terraform.tfvars
C..terraform.lock.hcl
D.provider.tf
AnswerC

This is the lock file for providers.

Why this answer

.terraform.lock.hcl is the dependency lock file.

119
Multi-Selecteasy

Which of the following are valid ways to specify provider versions? (Select TWO)

Select 2 answers
A.In the required_providers block.
B.In the resource block.
C.In the backend block.
D.In the provider block using the 'version' argument (deprecated).
E.In the output block.
AnswersA, D

This is the primary way.

Why this answer

Version constraints can be specified in the required_providers block and through CLI variables (though the latter is less common).

120
MCQmedium

How can you debug the output of a complex 'for' expression in Terraform?

A.Check the state file
B.Use terraform plan
C.Use terraform console
D.Use terraform debug
AnswerC

terraform console provides an interactive REPL for testing HCL.

Why this answer

The 'terraform console' command is the standard way to interactively evaluate HCL expressions and debug complex transformations.

121
Multi-Selectmedium

Which THREE of the following are consequences of drifting from the Terraform state?

Select 3 answers
A.The plan may show changes even if the config hasn't changed.
B.It can lead to 'Resource Not Found' errors if someone manually deletes an item.
C.It disables the use of lifecycle meta-arguments.
D.Terraform may attempt to revert changes during the next apply.
E.It automatically updates the configuration file.
AnswersA, B, D

This is the hallmark of drift.

Why this answer

Drift causes mismatches, unexpected results, and potential failure during destructive actions.

122
Multi-Selectmedium

Which THREE pieces of information are displayed in the HCP Terraform Run UI?

Select 3 answers
A.The user who initiated the run
B.The raw state file in plain text
C.Policy check status
D.Plan output
E.Private cloud provider passwords
AnswersA, C, D

Audit logs record the initiator.

Why this answer

The UI shows the plan output, the policy check status, and the user who initiated the run.

123
Multi-Selectmedium

When debugging provider issues, which commands are most useful? (Select THREE)

Select 3 answers
A.terraform providers
B.TF_LOG=DEBUG
C.terraform fmt
D.terraform taint
E.terraform init
AnswersA, B, E

Shows provider dependencies.

Why this answer

terraform providers, terraform init, and TF_LOG are the standard ways to troubleshoot provider issues.

124
MCQmedium

You want to automate the approval process for non-production environments in HCP Terraform. Which setting enables this?

A.Configure Run Triggers
B.Set Sentinel policy to advisory
C.Enable Auto-apply
D.Use API-driven workflows
AnswerC

Auto-apply removes the manual approval step.

Why this answer

Auto-apply in workspace settings allows runs to proceed to completion without manual intervention.

125
MCQmedium

If a resource is not specified with a provider meta-argument, which provider instance does it use?

A.The first one defined.
B.The provider configuration without an alias.
C.The one with the latest version.
D.It causes an error.
AnswerB

Resources implicitly use the default provider configuration.

Why this answer

It defaults to the instance of that provider without an alias.

126
MCQhard

If you have a module that creates an S3 bucket, and you want the bucket name to be prefixed by a value provided by the caller, how do you achieve this?

A.Use a local variable that reads from the provider config.
B.Use string interpolation in the bucket name attribute.
C.Define the bucket name in the root module and override the child resource.
D.Use the 'module_name' variable provided by Terraform.
AnswerB

Interpolating the input variable into the bucket name is the standard approach.

Why this answer

Concatenate the variable inside the resource block using string interpolation.

127
MCQeasy

When using 'for_each' on a list of strings, what must you do to ensure the configuration is stable?

A.Use count instead
B.Convert the list to a set
C.Use the index
D.Nothing, it's always stable
AnswerB

Converting to a set provides stable keys based on the value content.

Why this answer

Using a list directly with for_each is often unstable if the list order changes. Converting it to a set with toset() ensures each item has a stable key.

128
Multi-Selectmedium

Which THREE of the following are true about 'lifecycle' blocks?

Select 3 answers
A.They are defined inside the resource configuration block.
B.Multiple lifecycle arguments can be used in one block.
C.They allow changing the provider version dynamically.
D.They are inherited from the provider block.
E.They are evaluated during the planning phase.
AnswersA, B, E

Correct location.

Why this answer

They are per-resource, support specific arguments, and are defined inside the resource body.

129
Multi-Selectmedium

Which THREE of these are reasons to use the 'ignore_changes' lifecycle meta-argument?

Select 3 answers
A.To ignore tags applied by external cost-allocation tools.
B.To force the creation of a new resource.
C.To stop Terraform from reverting auto-scaling group capacity changes.
D.To prevent Terraform from destroying a database.
E.To ignore changes to an S3 bucket's 'last_modified_date'.
AnswersA, C, E

Valid use case.

Why this answer

These are common scenarios for ignoring drifts or auto-populated fields in Terraform.

130
MCQeasy

Which function is most useful when you have a nested list of objects and want to create a single flat list to iterate over with for_each?

A.concat()
B.flatten()
C.lookup()
D.merge()
AnswerB

flatten simplifies nested list structures into a single list.

Why this answer

The flatten() function is specifically designed to take nested lists and turn them into a single-level list.

131
MCQhard

You are managing a production database instance. You want to ensure that if a developer accidentally removes the resource block from the Terraform configuration, Terraform will refuse to destroy the database. How do you implement this?

A.Set prevent_destroy = true in the lifecycle block.
B.Set create_before_destroy = false.
C.Use the ignore_changes meta-argument for the lifecycle block.
D.Configure a provider-level block to disable deletions.
AnswerA

This is the correct configuration for preventing accidental deletion.

Why this answer

The prevent_destroy lifecycle meta-argument is a safety measure that causes a plan to fail if a resource is marked for deletion.

132
MCQhard

You have an AWS Lambda function that should be replaced whenever the source code S3 object changes. How do you trigger this replacement specifically based on the S3 object key change?

A.Use lifecycle { force_replace = true }
B.Use replace_triggered_by = [aws_s3_object.lambda_code.key]
C.Use create_before_destroy.
D.Use ignore_changes = [source_code_hash]
AnswerB

This correctly references the attribute change to trigger replacement.

Why this answer

The replace_triggered_by meta-argument allows forcing a resource to be replaced when another specified resource or attribute changes.

133
MCQmedium

When using multiple provider instances with different regions, what must be defined in the provider configuration?

A.A unique alias identifier.
B.A unique project ID.
C.A credentials object.
D.A version constraint in each block.
AnswerA

Alias is required to distinguish multiple instances of the same provider.

Why this answer

You must provide an alias for every provider instance except for the default one.

134
MCQmedium

Your team requires a custom module to be versioned strictly to prevent breaking changes during deployments. What is the recommended way to reference a module from a private Git repository?

A.Use the 'ref' parameter in the source URL string.
B.Set the 'version' block inside the module definition.
C.Copy the module code locally every time a new version is released.
D.Use the 'module_version' argument in the module block.
AnswerA

The 'ref' query parameter in the source URL specifies the version, tag, or branch.

Why this answer

Using the 'version' argument in the source block allows pinning to specific tags or branches, ensuring stability.

135
MCQhard

How can you protect a module's inputs from receiving incorrect types of data?

A.Use the 'provider' block to enforce input types.
B.Use a 'validation' block with a condition inside the variable declaration.
C.Write a custom bash script to check the inputs.
D.Terraform automatically validates all inputs as strings.
AnswerB

Validation blocks provide a way to enforce custom business logic on inputs.

Why this answer

Defining the 'type' constraint in the variable block ensures Terraform validates the input before applying changes.

136
MCQmedium

When using 'create_before_destroy', what is a common side effect that may cause the plan to fail?

A.Resource naming collisions.
B.Terraform will delete the state file.
C.Provider credentials will expire.
D.All other resources will be destroyed.
AnswerA

The new resource cannot be created if the name is already taken by the existing one.

Why this answer

If the resource has a unique name or specific constraints (like an S3 bucket name), creating a new instance before destroying the old one will cause a naming collision.

137
MCQhard

In HCL, how do you handle a scenario where a variable might be null but you need to provide a non-null default value for a resource argument?

A.using try()
B.using count
C.using coalesce()
D.using for_each
AnswerC

coalesce() returns the first non-null argument, making it perfect for defaults.

Why this answer

The coalesce() function is ideal for providing a fallback value if the primary input is null.

138
MCQeasy

Where are providers physically stored by default when running 'terraform init'?

A.The root module directory
B.~/.terraformrc
C..terraform/providers/
D./usr/local/bin/terraform
AnswerC

This is the default local cache directory.

Why this answer

Terraform downloads providers into the .terraform/providers directory within your project working directory.

139
MCQeasy

Which function allows you to safely access a map value even if the key might not exist?

A.try()
B.element()
C.lookup()
D.coalesce()
AnswerC

lookup() is designed to provide a default if a key is missing.

Why this answer

The lookup() function allows you to provide a default value to return if the requested key is not found in the map.

140
MCQmedium

You are configuring RBAC in HCP Terraform. A user needs to trigger runs and view plan logs but should not be allowed to modify workspace variables. Which permission set is appropriate?

A.Grant Admin access.
B.Grant 'Read' and 'Queue Plan' permissions.
C.Grant 'Manage Variables' permission.
D.Grant 'Write' permission to the workspace.
AnswerB

Queue Plan allows triggering runs, while Read allows viewing logs without changing variables.

Why this answer

The 'read' and 'write' permissions are distinct. Specifically, the 'Plan' permission allows triggering runs, while 'Manage' permissions are required for variables.

141
MCQhard

A Sentinel policy is failing on a cost estimation result. What is the most likely cause if the cost estimation feature is enabled but the policy still fails?

A.The cost estimation provider is not configured for AWS.
B.The workspace does not have Sentinel enabled.
C.The API key for AWS is invalid.
D.The policy attempts to access cost data before the estimation has completed.
AnswerD

Policies run after the plan; if cost estimation hasn't finalized, the policy might throw an error.

Why this answer

Sentinel policies can access the cost estimation data via the 'tfrun' import, but if the estimation is still in progress or failed to generate, the policy will fail.

142
MCQhard

You need to output a complex object from a child module to be used by the root module. What is the best practice for defining the output?

A.Assign the output to a global variable in the root module.
B.Use a data source to read the child module's internal state.
C.Define an output block in the child module and reference it in the root module using the module prefix.
D.Write the output to a local file inside the module and read it in the root.
AnswerC

This is the standard pattern for passing information from a module back to its caller.

Why this answer

Using explicit output blocks in the child module makes the data available for access via 'module.<module_name>.<output_name>'.

143
MCQhard

You are attempting to use a conditional expression to set a variable, but the types returned by the true and false results differ. What happens?

A.The result is coerced to a string
B.A type mismatch error is returned
C.It defaults to the true result type
D.Terraform automatically casts to the most flexible type
AnswerB

Terraform demands that both expressions return the same type.

Why this answer

Terraform requires that both branches of a conditional expression return the same type, otherwise it will throw a type mismatch error during the planning phase.

144
MCQhard

In a workspace, you define a variable named 'region'. How can you override this value for a specific run without changing the workspace configuration?

A.By editing the state file
B.By modifying the provider block
C.Using -var flag in terraform apply
D.By adding a new workspace
AnswerC

CLI flags override workspace variables for that specific run.

Why this answer

CLI-driven runs or API overrides can pass different variables to a specific run execution.

145
MCQhard

What is the result of a 'soft-mandatory' Sentinel policy failing during a run?

A.The run is immediately aborted.
B.The policy is skipped automatically.
C.The run pauses and waits for an override.
D.The run completes but triggers an alert.
AnswerC

Soft-mandatory policies require manual override to proceed.

Why this answer

Soft-mandatory policies allow a user with the appropriate permissions to override the failure and continue the run.

146
MCQmedium

You need to share a module across your entire organization. Which registry type should you use?

A.The public Terraform Registry.
B.A shared network drive.
C.An S3 bucket with public read access.
D.A private module registry in Terraform Cloud or Enterprise.
AnswerD

Private registries are designed for secure, internal module distribution.

Why this answer

Terraform Cloud or Terraform Enterprise private module registries are the standard for internal organization-wide sharing.

147
MCQmedium

You are managing state in a multi-region deployment. You need to ensure that simultaneous terraform apply operations do not corrupt the state file. Which backend configuration parameter primarily enables this functionality?

A.workspace_key_prefix
B.kms_key_id
C.acl
D.dynamodb_table
AnswerD

DynamoDB tables are the standard mechanism for S3 state locking.

Why this answer

The 'dynamodb_table' parameter is used with the S3 backend to enable state locking, preventing concurrent operations.

148
MCQmedium

You have a nested module structure. How can you pass a variable from the root module through an intermediate module to a leaf module?

A.Define the variable only in the leaf module and refer to root by index.
B.You must define the variable in the intermediate module and pass it to the leaf module.
C.You can use the 'global_vars' block in the root.
D.The intermediate module automatically inherits all root variables.
AnswerB

Explicit declaration and assignment are required at every level of the hierarchy.

Why this answer

Each intermediate module must define a variable and then pass it down using the 'source' or 'module' call block.

149
MCQhard

You are writing an OPA (Open Policy Agent) policy to restrict resource creation. You want to deny any EC2 instance that does not include the 'CostCenter' tag. How do you access the resource attributes in the policy?

A.terraform.tags
B.input.resource_changes
C.state.output
D.var.tags
AnswerB

input.resource_changes contains the details of planned modifications.

Why this answer

In OPA/Sentinel, you access the plan data structure which contains the resource changes and their associated attributes.

150
MCQeasy

What is the primary difference between 'count' and 'for_each' regarding state management?

A.for_each is only for maps
B.for_each does not support complex objects
C.count is faster than for_each
D.count uses index-based indexing, causing potential recreation when items are removed
AnswerD

Because count uses integer indices, changing the list order or removing items causes index shifts.

Why this answer

count depends on list order, so removing an item from the middle of the list causes all subsequent resources to be recreated. for_each uses keys, which are stable.

Page 1

Page 2 of 3

Page 3

All pages