Explain HCP Terraform workflows: VCS-driven, CLI-driven and API-driven.
BeginnerScenarioPipelines Terraform Cloud and OpenTofu
Answer
Situation read → A teammate is new to HCP Terraform workspaces.
What I'd do →
- VCS-driven: connect a repo; pushes trigger plans, merges trigger applies, PRs get speculative plans.
- CLI-driven:
terraform planruns remotely via thecloudblock, with state and runs in HCP. - API-driven: pipelines upload configuration versions and create runs via API for custom flows.
terraform {
cloud {
organization = "acme"
workspaces { name = "network-prod" }
}
}
Why → Pick by where you want the trigger: Git events, developers, or your own automation.
Interview tip → A workspace is state plus variables plus runs plus permissions.
More on Pipelines Terraform Cloud and OpenTofu
Build a basic GitHub Actions pipeline: plan on pull request, apply on merge to main.BeginnerReviewers can't read raw plan logs. How do you present the plan in the PR?IntermediateTwo PRs merge close together and both apply to the same stack. What prevents trouble?IntermediateHow do you add a manual approval before prod applies?IntermediateCompare Atlantis, HCP Terraform and a hand-built GitHub Actions pipeline.IntermediateA saved plan was approved yesterday and apply fails because main changed. How do you avoid dead approvals?Intermediate