Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Terraform: Step‑By‑Step: Use Local CLI to Modify Remote State in TFE

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

  1. 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.

  1. Authenticate to HCP/TFE
   terraform login
  1. 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)
  1. Initialize the backend
   terraform init
  1. Confirm the remote state is reachable
   terraform state listCode language: PHP (php)
  1. Modify remote state (example: untaint)
   terraform untaint 'module.k8s_az_anchor[0].kubernetes_manifest.priority_class[0]'Code language: JavaScript (javascript)
  1. 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):

  1. Plan (remote run)
   terraform plan
  1. Apply (remote run)
   terraform apply
  1. Destroy (remote run)
   terraform destroy

Alternative:

   terraform apply -destroy
  1. Import (writes to remote state)
   terraform import <resource_address> <remote_id>Code language: HTML, XML (xml)
  1. Refresh only (safe read/update of state)
   terraform plan -refresh-only
  1. State list (remote state)
   terraform state listCode language: PHP (php)
  1. State show (remote state)
   terraform state show <resource_address>Code language: HTML, XML (xml)
  1. State move (remote state)
   terraform state mv <old_address> <new_address>Code language: HTML, XML (xml)
  1. State remove (remote state)
   terraform state rm <resource_address>Code language: HTML, XML (xml)
  1. State pull (remote → local file) terraform state pull > /tmp/tfstate.json
  2. State push (local file → remote) terraform state push /tmp/tfstate.json
  3. Replace provider in state (remote state) terraform state replace-provider <old_provider> <new_provider>
  4. Taint / Untaint (if supported by your version) terraform taint <resource_address> terraform untaint <resource_address>
  5. Force unlock remote state (rare) terraform force-unlock <LOCK_ID>
  6. 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/import will 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?

  1. VCS‑connected + CLI runs allowed
  2. VCS‑connected + CLI runs disabled
  3. CLI‑driven workspace (no VCS)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x