002 · Domain 4: CI/CD and Automation Workflows · 10% of the exam
Task 4.3: Manage multiple sets of dynamic provider credentials across teams, projects, and workspaces
Workload identity in HCP Terraform at scale: the TFC_* variables, variable sets per project, trust policies on token claims, and multiple configurations with tags for more than one account.
Study it
Dynamic provider credentials for many teams, projects and workspaces
Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.
Question 1 · choose 1
Every current and future workspace in the payments project must get AWS credentials through dynamic provider credentials. Plans must run with a read-only role and applies with a write role, and no workspace outside the organization's payments project may assume either role. Which setup meets all three requirements?
AA global variable set covering the project, with TFC_DEFAULT_AWS_PROVIDER_AUTH and TFC_DEFAULT_AWS_RUN_ROLE_ARN
BA project-scoped variable set with TFC_AWS_PROVIDER_AUTH and one TFC_AWS_RUN_ROLE_ARN whose trust policy matches run_phase:*
CA project-scoped variable set with plan and apply role ARNs, each role trusting only the aud claim
DA project-scoped variable set with plan and apply role ARNs; each role trusts aud and a sub naming the org, project and its run phase
Show the answer and why
AA global variable set covering the project, with TFC_DEFAULT_AWS_PROVIDER_AUTH and TFC_DEFAULT_AWS_RUN_ROLE_ARN
Incorrect
TFC_AWS_PROVIDER_AUTH has no default variant, a global set reaches every project, and one run role cannot separate plan from apply.
BA project-scoped variable set with TFC_AWS_PROVIDER_AUTH and one TFC_AWS_RUN_ROLE_ARN whose trust policy matches run_phase:*
Incorrect
A single role trusted for every run phase gives plans the same write access as applies.
CA project-scoped variable set with plan and apply role ARNs, each role trusting only the aud claim
Incorrect
Checking only the audience lets workspaces in other projects and other organizations assume the roles.
DA project-scoped variable set with plan and apply role ARNs; each role trusts aud and a sub naming the org, project and its run phase
Correct
The project-scoped set reaches all current and future workspaces in the project, and separate roles matched on run_phase give plan and apply different permissions.
Share credentials configuration through a project-scoped variable set, separate TFC_AWS_PLAN_ROLE_ARN and TFC_AWS_APPLY_ROLE_ARN roles, and trust policies whose sub condition names the organization, the project and the run phase.
Dynamic AWS credentials worked for every workspace in a project until an administrator renamed the project from "Default Project" to "platform". Since then, runs fail when assuming the role. What should the team change?
ARegenerate the OIDC provider's thumbprint in AWS after the rename rotates HCP Terraform's signing key
BSet TFC_AWS_WORKLOAD_IDENTITY_AUDIENCE to the new project name in the workspaces
CUpdate the role's trust policy sub condition to the new project name
DCreate a new team API token scoped to the renamed project
Show the answer and why
ARegenerate the OIDC provider's thumbprint in AWS after the rename rotates HCP Terraform's signing key
Incorrect
Renaming a project does not change HCP Terraform's signing keys; the token is still verified correctly.
BSet TFC_AWS_WORKLOAD_IDENTITY_AUDIENCE to the new project name in the workspaces
Incorrect
The audience is a separate claim and must keep matching the value the role trusts; it does not hold the project name.
CUpdate the role's trust policy sub condition to the new project name
Correct
The sub claim contains the organization, project and workspace names, and HashiCorp notes that these names can change, so the condition must follow the rename.
DCreate a new team API token scoped to the renamed project
Incorrect
Dynamic credentials do not use team API tokens; the run receives a workload identity token.
Trust policies usually match on names in the sub claim. Renaming an organization, project or workspace changes those names, so update the conditions, or match on claims that suit how often names change.
A platform team enables dynamic AWS credentials for private registry module tests. The role trusts sub values matching organization:acme:project:*:workspace:*:run_phase:*, which works for workspace runs, but test runs cannot assume the role. Why?
ATest runs request tokens for the apply phase, which the policy blocks
BModule tests cannot use dynamic provider credentials in HCP Terraform at all
CTest tokens are valid only after terraform login on a workstation
DTest tokens use sub organization:acme:module:<NAME>:operation:test_run
Show the answer and why
ATest runs request tokens for the apply phase, which the policy blocks
Incorrect
Test run tokens always use the plan phase, and the condition already allows any phase.
BModule tests cannot use dynamic provider credentials in HCP Terraform at all
Incorrect
HCP Terraform generates workload identity tokens specifically for module test runs.
CTest tokens are valid only after terraform login on a workstation
Incorrect
HCP Terraform issues the tokens for the test run itself; no workstation login is involved.
DTest tokens use sub organization:acme:module:<NAME>:operation:test_run
Correct
Module test tokens have a different subject format and carry no project or workspace claims, so a condition written for workspace runs does not match them.
Add a trust condition for the module test subject, scoped to the organization and the module, next to the conditions for workspace runs.