SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
Terraform Pro 002 · Domain 5

Terraform security and governance practice questions

Terraform security and governance is worth 13% of the Terraform Pro 002 exam — the 3rd-heaviest of the 7 domains. Secrets handling and rotation, securing pipeline identities, organisation and team policy rules, and catching risky changes. Weight approximates the sub-objective share. 6 fully worked examples are further down this page, answers included.

Exam weight
13%
the 3rd-heaviest of the 7 domains
Questions
98
across 2 topics
Free, no account
5/day
a free account allows 10 a day
Explanations
Every option
right and wrong

Build a practice session

5 free questions left today.

Domains

How many?

Mode

Ready when you are

10 fresh questions drawn across 1 of 7 domains, in Learn mode.

Review what you missed

Every question you answer incorrectly, and every question you flag while practising, is saved here automatically. Finish a session and you can come back to re-drill just those.

6 sample Terraform security and governance questions, fully explained

Questions from the Terraform Pro 002 bank mapped to domain 5, with the answer key and the reasoning behind every option. None of them repeat the examples on the main Terraform Pro 002 practice page.

Question 1Terraform security and governance

An engineer accidentally marked an HCP Terraform workspace variable as sensitive. It holds a non-secret value, the default region, which the team wants to see in the UI again. What must the engineer do?

Choose one.

  • a
    Delete the variable and create a new non-sensitive one with that key Correct

    HCP Terraform documents that to change other attributes of a sensitive variable you delete it and create a replacement.

  • b
    Edit the variable and clear its Sensitive setting, then save it

    A sensitive variable's other attributes cannot be modified; only its value can be replaced, so the setting cannot be cleared in place.

  • c
    Read its value through the Variables API and save it as non-sensitive

    Sensitive variables are write-only: the Variables API does not return their values either.

  • d
    Ask an organization owner to reveal the value on the variable's page

    No role can view a sensitive variable's value in the UI, owners included.

The concept

Sensitive HCP Terraform variables are write-only: no user or API call can read them back, and their attributes cannot be edited.

Why that’s the answer

Marking a variable sensitive makes it write-only for everyone, including organization owners and API clients. Its value can be replaced, but its other attributes, such as the sensitive flag, cannot be changed. The documented route is to delete the variable and create a new one with the same key and the desired settings.

How to reason it out
  1. Recall that sensitive means write-only for all users and the API.
  2. Note that the sensitive flag is one of the attributes that cannot be edited.
  3. Choose deleting and recreating the variable.

Exam tip: A sensitive workspace variable can be replaced or deleted, never unmasked or edited back.

Terraform Professional (002): Secrets, Rotation and Pipeline Identities — the lesson that teaches this.

Question 2Terraform security and governance

An HCP Terraform workspace holds AWS access keys as sensitive environment variables and a database password as a sensitive Terraform variable. The configuration passes the password to the password argument of an aws_db_instance. While debugging, an engineer sets TF_LOG=TRACE on the workspace. Which TWO statements are true? (Select TWO.)

Choose TWO.

  • a
    The AWS access keys are written to state with the run's environment

    Environment variables are not stored in state; the exposure risk for them is the TRACE log.

  • b
    Users with Write access can read both values through the Variables API

    Sensitive variables are write-only for every user and API client, regardless of workspace permission.

  • c
    The database password is written to the state file Correct

    The value is sent to an ordinary resource argument, so Terraform records it in state; the workspace's sensitive flag does not change that.

  • d
    The database password is redacted in state because the variable is sensitive

    Sensitivity redacts display; the provider still stores the argument's value in state.

  • e
    That log level can write the environment variable values into run logs Correct

    HCP Terraform warns that environment variables are not stored in state but can be included in log files when TF_LOG is TRACE.

The concept

A sensitive workspace variable hides the value in HCP Terraform's UI and API, but the run receives the full value and can still put it into state or logs.

Why that’s the answer

Two facts combine. First, the run gets the real value, and an ordinary resource argument is persisted in state, so the password is in state no matter how the variable was flagged. Second, environment variables never reach state, but HashiCorp documents that TF_LOG=TRACE can print them into run logs. Sensitive variables are never readable through the API, and nothing redacts values inside state.

How to reason it out
  1. Separate the two variable categories: environment variables and Terraform variables.
  2. Ask where each value flows: an ordinary resource argument is persisted in state.
  3. Recall that TRACE logging can include environment variables.
  4. Reject claims that sensitive values are readable through the API or redacted in state.

Exam tip: Sensitive hides a value from people, not from the run: watch state and TRACE logs.

Terraform Professional (002): Secrets, Rotation and Pipeline Identities — the lesson that teaches this.

Question 3Terraform security and governance

An audit team needs to view the outputs of a production HCP Terraform workspace, such as VPC and subnet IDs. The workspace's state also contains database credentials, which the auditors must not be able to retrieve. Which workspace access should the audit team get?

Choose one.

  • a
    Custom access with state versions set to Read outputs only Correct

    Read outputs only grants access to the workspace's public outputs without the full state file.

  • b
    The fixed Read permission set on the production workspace

    The fixed Read set includes reading complete state versions, so the credentials in state would be downloadable.

  • c
    Custom access with state versions set to Read on the workspace

    Read on state versions means reading complete state files, which include the credentials.

  • d
    The fixed Plan permission set on the production workspace

    Plan adds the ability to queue plans and still includes reading complete state versions.

The concept

In HCP Terraform, reading state versions means reading the full state, secrets included; outputs-only access is a separate custom permission level.

Why that’s the answer

Every fixed permission set, Read included, can read complete state versions. Because state can hold secrets, a team that only needs outputs should get custom workspace access with state versions set to Read outputs only. Custom Read on state versions is the near-twin and exposes the full file.

How to reason it out
  1. Note that the state contains credentials.
  2. Recall that every fixed permission set includes reading full state versions.
  3. Pick the custom level that exposes only outputs.

Exam tip: Outputs-only consumers get 'Read outputs only', never a set that reads full state.

Terraform Professional (002): Secrets, Rotation and Pipeline Identities — the lesson that teaches this.

Question 4Terraform security and governance

A platform team gave a developers team the fixed Plan permission set on a production workspace so that developers could queue plans but never apply them or see secrets. A security review then shows a developer downloaded a database password. What explains this?

Choose one.

  • a
    The Plan set includes reading the values of sensitive workspace variables

    Sensitive variable values cannot be read by any user, whatever permission set they hold.

  • b
    The Plan set includes printing sensitive values in the plan's run log

    Terraform redacts sensitive values in plan output; the plan log does not show the password.

  • c
    The Plan set includes writing new state versions to the workspace

    Writing state versions is part of Write and Admin, and writing is not how a value is read anyway.

  • d
    The Plan set includes reading complete state versions of the workspace Correct

    All fixed permission sets include reading state versions, and the database password is stored in state.

The concept

Read access to state versions is part of every fixed workspace permission set, so state holding secrets is exposed to any team with workspace access.

Why that’s the answer

The Plan set lets a team queue plans, and like every fixed set it also includes reading complete state versions. Because the password was passed to a resource argument it is in state, so the developer could download it. Sensitive variables are never readable, plan logs redact sensitive values, and writing state is a Write/Admin capability.

How to reason it out
  1. Identify where the password can be read: state, not the variable.
  2. Recall what the fixed Plan set includes besides queuing plans.
  3. Rule out the variable and log options, which stay hidden.

Exam tip: Any fixed workspace permission set can read full state; protect state as a secret.

Terraform Professional (002): Secrets, Rotation and Pipeline Identities — the lesson that teaches this.

Question 5Terraform security and governance

A Terraform 1.15 configuration contains:ephemeral "vault_kv_secret_v2" "app" { mount = "kv" name = "payments/api" } resource "kubernetes_secret_v1" "api" { metadata { name = "payments-api" } data = { token = ephemeral.vault_kv_secret_v2.app.data["token"] } }What happens when the team runs terraform plan?

Choose one.

  • a
    Plan succeeds and the token is stored in state but shown as sensitive

    Terraform does not convert an ephemeral reference into a stored sensitive value; it rejects the reference.

  • b
    Plan succeeds and the token is sent to Kubernetes but left out of state

    Only write-only arguments receive values without persisting them; data is an ordinary argument.

  • c
    Plan fails because an ephemeral value is used in an ordinary argument Correct

    Ephemeral resource attributes may only be referenced in write-only arguments, provider and provisioner configuration, locals, other ephemeral blocks and ephemeral variables or outputs; data is none of these.

  • d
    Plan defers the secret until apply because the token is not yet known

    Deferral applies when an ephemeral block's inputs are unknown; it does not make an invalid reference valid.

The concept

Ephemeral resource results are valid only in a short list of contexts; using one in an ordinary managed-resource argument is a plan-time error.

Why that’s the answer

Terraform throws an error at plan time when an ephemeral resource is referenced outside the permitted contexts: write-only arguments, other ephemeral blocks, locals, ephemeral variables and child-module outputs, provider configuration, and provisioner/connection blocks. The data map of kubernetes_secret_v1 is an ordinary argument that would be persisted, so the configuration is invalid rather than silently stored or redacted.

How to reason it out
  1. Identify the reference: an ephemeral attribute flows into a managed resource.
  2. Check whether the argument is write-only; data is not.
  3. Recall that invalid ephemeral references fail at plan.

Exam tip: Ephemeral values may only flow into places Terraform never persists.

Terraform Professional (002): Secrets, Rotation and Pipeline Identities — the lesson that teaches this.

Question 6Terraform security and governance

A module reads a short-lived credential with an ephemeral resource so that the credential never reaches state or plan files. Where in a Terraform 1.15 configuration may the ephemeral resource's attributes be referenced? (Select TWO.)

Choose TWO.

  • a
    A root module output block marked sensitive = true

    Root module outputs are stored in state and cannot be ephemeral; sensitive only redacts display.

  • b
    The tags argument of a managed resource

    tags is an ordinary argument recorded in state, so an ephemeral reference there is an error.

  • c
    An argument inside a provider block's configuration Correct

    Provider configuration is a permitted context for ephemeral values; it is never stored.

  • d
    A write-only argument of a managed resource Correct

    Write-only arguments are designed to accept ephemeral values and are not persisted.

  • e
    An argument of a data block that looks up a network

    Data source arguments are not in the permitted list for ephemeral values.

The concept

Ephemeral values can be used only where Terraform does not persist them.

Why that’s the answer

The permitted contexts are write-only arguments, provider configuration, locals, other ephemeral blocks, ephemeral variables and child-module outputs, and provisioner/connection configuration. Root outputs, ordinary resource arguments such as tags and data source arguments all end up in state or plan, so references there fail at plan time.

How to reason it out
  1. Ask whether each location is persisted in state or plan.
  2. Recall the permitted contexts list.
  3. Note that sensitive = true does not make a root output ephemeral.

Exam tip: Provider config and write-only arguments take ephemeral values; anything persisted does not.

Terraform Professional (002): Secrets, Rotation and Pipeline Identities — the lesson that teaches this.

What Terraform Pro 002 domain 5 tests, topic by topic

The official exam guide breaks Terraform security and governance into 2 topics. The question bank follows the same split, so a weak topic shows up as a cluster of misses you can go back and read.

Published Terraform Pro 002 practice questions per topic in Terraform security and governance
TopicWhat it coversQuestions
Secrets and pipeline identitiesOfficial Terraform Infrastructure Engineer Professional (002) objectives, 5a Identify best practices for secrets; 5b Use secret rotation and integration with secrets management tools; 5c Secure CI/CD pipeline identities and access.50
Policy rules and risky infrastructure changesOfficial Terraform Infrastructure Engineer Professional (002) objectives, 5d Establish core compliance/policy rules along with Team/Project specific policies; 5e Identify and mitigate risky infrastructure changes.48
Total98

Revise Terraform security and governance before you drill it

Other Terraform Pro 002 domains

Terraform security and governance: your questions

Terraform security and governance is domain 5 of the Terraform Pro 002 exam guide and carries 13% of the scored content — the 3rd-heaviest of the 7 domains. HashiCorp has not yet published the exam's question count, so there is no per-domain number of questions to give.

Source

The domain weight and topic list on this page come from the official Terraform Pro 002 exam guide.