Below is a step‑by‑step tutorial for using the Terraform CLI against a VCS‑connected HCP/TFE workspace, plus a command catalog for all the common remote actions.
Step‑By‑Step: Use Local CLI to Modify Remote State in TFE
- Verify your Terraform version matches the workspace requirement
terraform version
If the workspace requires ~>1.14.0, make sure you’re on 1.14.x.
- Authenticate to HCP/TFE
terraform login
- Set the remote workspace (pick one method) Option A: Use env vars (fast + explicit)
export TF_CLOUD_ORGANIZATION="Drivemode"
export TF_WORKSPACE="evp-aws-development-core"Code language: JavaScript (javascript)
Option B: Use workspace selection after init
terraform init
terraform workspace list
terraform workspace select evp-aws-development-coreCode language: PHP (php)
- Initialize the backend
terraform init
- Confirm the remote state is reachable
terraform state listCode language: PHP (php)
- Modify remote state (example: untaint)
terraform untaint 'module.k8s_az_anchor[0].kubernetes_manifest.priority_class[0]'Code language: JavaScript (javascript)
- Verify the plan is now clean
terraform plan
That flow modifies the remote state in TFE because your backend is remote and the CLI is authenticated.
Remote Run Commands (All Common Commands That Run Remote Actions)
These commands create or change remote resources (or interact with remote state):
- Plan (remote run)
terraform plan
- Apply (remote run)
terraform apply
- Destroy (remote run)
terraform destroy
Alternative:
terraform apply -destroy
- Import (writes to remote state)
terraform import <resource_address> <remote_id>Code language: HTML, XML (xml)
- Refresh only (safe read/update of state)
terraform plan -refresh-only
- State list (remote state)
terraform state listCode language: PHP (php)
- State show (remote state)
terraform state show <resource_address>Code language: HTML, XML (xml)
- State move (remote state)
terraform state mv <old_address> <new_address>Code language: HTML, XML (xml)
- State remove (remote state)
terraform state rm <resource_address>Code language: HTML, XML (xml)
- State pull (remote → local file)
terraform state pull > /tmp/tfstate.json - State push (local file → remote)
terraform state push /tmp/tfstate.json - Replace provider in state (remote state)
terraform state replace-provider <old_provider> <new_provider> - Taint / Untaint (if supported by your version)
terraform taint <resource_address> terraform untaint <resource_address> - Force unlock remote state (rare)
terraform force-unlock <LOCK_ID> - Show outputs (remote state)
bash terraform output
Important behavior in VCS‑connected workspaces
- CLI runs use your local config snapshot, not the Git branch snapshot.
- If CLI‑driven runs are disabled in the workspace,
plan/apply/importwill fail. - State commands still work if your org policy allows and your version matches.
If you want, I can tailor this to your exact workspace settings. Which one is your workspace using?
- VCS‑connected + CLI runs allowed
- VCS‑connected + CLI runs disabled
- CLI‑driven workspace (no VCS)
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals
Good article! It explains how to use the Terraform CLI to modify remote state in Terraform Enterprise step by step. Very helpful for anyone working with Terraform and remote state management.