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
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Complete Marp installation + command + examples guide

Marp is a Markdown presentation ecosystem. Marp CLI converts Marp/Marpit Markdown files into static HTML/CSS, PDF, PowerPoint/PPTX, and images. The official CLI docs also say Node.js v18+…

Read More

Complete practical Quarto installation + command guide

Quarto is an open-source technical publishing system built on Pandoc. It can create documents, websites, blogs, books, and slides, and supports authoring in Markdown-like .qmd files. It…

Read More

The Best Way to Create Slides for Educators: A High-Level Guide to Automated Course Slide Generation

Meta Description A complete high-level guide for educators, trainers, and course creators on how to automate slide creation using Markdown, templates, images, reusable content, and multi-format exports…

Read More

Quarto vs Marp: The Complete Educator’s Guide to Automated Slide Creation Using Markdown

Meta Description A complete tutorial comparing Quarto and Marp for educators, trainers, DevOps instructors, and course creators. Learn which tool to use for automated slides, PPTX, PDF,…

Read More

Strategic Reliability: Mastering Service Level Objectives in Modern DevOps

Introduction In the early days of IT operations, reliability was often reduced to a binary metric: was the system up or down? This rigid pursuit of “five-nines”…

Read More

DevOps KPIs: A Guide to Engineering Growth

Introduction Engineering teams often prioritize speed, yet without clear, measurable indicators, growth frequently stalls amidst technical debt and reactive firefighting. To move from intuition to data-driven excellence,…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Jason Mitchell
Jason Mitchell
3 months ago

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.

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