Domain 8 of 8 · Chapter 4 of 4

Configure and Use HCP Terraform Integration

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • Connecting the CLI with the cloud block
  • Authenticating with terraform login
  • VCS-driven workspaces
  • Workspace variables, variable sets, and dynamic credentials

Getting provider credentials into a run

ApproachTerraform variable (var.name)Static environment variableDynamic provider credentials
Right place for provider auth?No, the classic anti-patternYes, the common approachYes, and stores no secret
Secret lifetimeNot applicableLong-lived, stored in the workspaceShort-lived, only for the run
How the run gets itAs var.name in configurationExported into the run shellIssued at run time via OIDC exchange
RotationNot applicableManualAutomatic, each run
Reuse across workspacesA variable setA variable setA variable set of its env vars

Decision tree

Authenticates a provider?Terraform variablevar.name in configAvoid a stored secret?Dynamic providercredentialsshort-lived, per runReused across workspaces?Environment variablein a variable set (shared)Environment variableon one workspaceA variable set shares any variable across workspaces; sensitive makes a variable write-onlyNoYesYesNoYesNo

Cheat sheet

  • The cloud block lives in the terraform block
  • workspaces uses name for one, tags for many
  • hostname defaults to app.terraform.io
  • terraform login retrieves an API token
  • Token is saved in credentials.tfrc.json
  • VCS integration installs a webhook to trigger runs
  • Terraform variables vs environment variables
  • Variable sets reuse variables across workspaces
  • Sensitive variables are write-only
  • HCP Terraform dynamic provider credentials

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. HCP Terraform CLI settings (the cloud block)
  2. Backend block configuration
  3. Command: terraform login
  4. Terraform CLI configuration file
  5. HCP Terraform VCS integration
  6. HCP Terraform workspace variables
  7. Managing variables and variable sets
  8. HCP Terraform dynamic provider credentials