Log in to Terraform Cloud/HCP
Open a browser flow to save an API token in the CLI credentials file.
terraform loginOpen a browser flow to save an API token in the CLI credentials file.
Commands and snippets for HCP Terraform remote runs, CLI auth, automation, and CI-friendly usage.
Authenticate Terraform CLI and configure credentials files.
Open a browser flow to save an API token in the CLI credentials file.
terraform loginOpen a browser flow to save an API token in the CLI credentials file.
Remove saved credentials for the current host.
terraform logoutRemove saved credentials for the current host.
Example `.terraformrc` / `terraform.rc` credentials block.
credentials "app.terraform.io" {
token = var.tfc_token
}Example `.terraformrc` / `terraform.rc` credentials block.
Useful flags and patterns for pipelines.
terraform plan -no-colorDisable ANSI color codes for cleaner CI logs.
terraform apply -auto-approve -input=falseApply non-interactively in automation.
terraform init -input=falseAvoid interactive backend/provider prompts in automation.
Common automation pattern for ephemeral or environment-specific workspaces.
terraform workspace select dev || terraform workspace new devCommon automation pattern for ephemeral or environment-specific workspaces.
Patterns for remote execution and uploaded configuration.
Map multiple CLI workspaces to remote workspaces with a shared prefix.
terraform {
backend "remote" {
organization = "acme"
workspaces {
prefix = "networking-"
}
}
}Map multiple CLI workspaces to remote workspaces with a shared prefix.
Isolate Terraform local data in ephemeral build environments.
export TF_DATA_DIR=$PWD/.tfdataIsolate Terraform local data in ephemeral build environments.
Use a project-specific CLI configuration in CI or containers.
export TF_CLI_CONFIG_FILE=$PWD/.terraformrcUse a project-specific CLI configuration in CI or containers.
Practical remote workflow patterns for teams.
Persist both binary and JSON plan outputs for later review or policy checks.
terraform plan -out=tfplan && terraform show -json tfplan > tfplan.jsonPersist both binary and JSON plan outputs for later review or policy checks.
terraform fmt -check -recursive && terraform init -backend=false && terraform validateCommon fast feedback step before plan/apply.