HashiCorp Terraform Associate (004) · Section 8 · 18% of the exam
Configure and use HCP Terraform integration
One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “HCP Terraform”. Here is what it covers, the points to remember and a question to try.
What it covers
How to authenticate with terraform login, configure the cloud block, migrate existing state, choose between name and tags, and run remote operations from the CLI and from a VCS repository.
Points to remember
- terraform login stores a user token in credentials.tfrc.json; it is interactive and defaults to app.terraform.io.
- For automation use a team or organization token in the credentials block or TF_TOKEN_<host> variable.
- The cloud block goes in the terraform block and replaces the backend block; it cannot hold variables.
- workspaces takes name or tags, never both; project is optional.
- TF_CLOUD_ORGANIZATION, TF_CLOUD_HOSTNAME, TF_CLOUD_PROJECT and TF_WORKSPACE can supply the values.
Try a question
A pipeline must run terraform apply against HCP Terraform without human login. What is the correct approach?
- ARun terraform login inside the pipeline and complete the browser prompt with a service account
- BCreate a team token and supply it as TF_TOKEN_app_terraform_io or in a credentials block
- CStore a user's password in the cloud block
- DUse the hostname of the registry as the token
Show the answer
B. Team tokens are not tied to a person, so the pipeline survives employee changes.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Connecting the CLI and VCS to HCP Terraform teaches this objective (about 40 minutes), and 16 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.