---
title: "The Easiest Way to Run Terraform in Visual Studio Code"
description: "Terraform code can be dry run in the editor (Visual Studio Code). You will know here how to do it the easy way."
url: https://srinimf.com/2023/04/01/the-easiest-way-to-run-terraform-in-visual-studio-code/
date: 2023-04-01
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2023/04/pexels-photo-590178.jpeg?fit=1733%2C1300&ssl=1
categories: ["Terraform"]
tags: ["1", "3", "4", "5", "Terraform on Visual Studio Code Editor"]
type: post
lang: en
---

# The Easiest Way to Run Terraform in Visual Studio Code

*Terraform is code for creating, modifying, and deleting infrastructure on the cloud. The terraform code can be dry run in the Visual Studio Code editor (VSC) before you apply it to the cloud environment such as AWS/AZURE/GC.*

Related[2 Top Terraform IDE Tools Ideal for DevOps Engineers](https://srinimf.com/2023/02/18/2-top-terraform-ide-tools-ideal-for-devops-engineers/)

## Dry run of Terraform codes

### #1 Install Terraform

Download the terraform for Windows from the [*download link*](https://developer.hashicorp.com/terraform/downloads). Copy the terraform.exe to the C drive folder (create a folder) C:Terraform, and set the .exe file path in Environment variables.

![Install Terraform](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/04/image.png?resize=1031%2C518&ssl=1)

### # 2 Install Visual studio code editor

The steps to install it are *[explained in my previous post](https://srinimf.com/2023/03/06/how-to-install-visual-studio-code-ide-to-write-terraform-code/)*. Follow the same.

### #3 Install the extension for Visual studio code

Go to the download link and install it and open the same in the VSC.

![Terraform extension for Visual Studio Code ](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/04/image-1.png?resize=887%2C611&ssl=1)

### #4 Verify Terraform installation

Open the VSC editor and terraform file folder. Consequently, it initiates Terraform environment. To check for terraform installation, open the command prompt (cmd) and issue the below command:

![Terraform version](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/04/image-2.png?resize=721%2C378&ssl=1)

### #5 Open Visual Studio Code editor

Open the VSC editor and terraform file (extension is .tf). And click on the Terminal button, and start issuing the below commands:

```
terraform init
terraform plan
```

![Visual Studio Code editor](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/04/image-3.png?resize=1154%2C710&ssl=1)

And, if there are no errors, run the below command, which applies changes to the cloud environment.

```
terraform apply
```

To sum up, these steps are helpful to do a dry run on your terraform code.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2023%2F04%2F01%2Fthe-easiest-way-to-run-terraform-in-visual-studio-code%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2023%2F04%2Fpexels-photo-590178.jpeg%3Ffit%3D1200%252C900%26ssl%3D1&description=The%20Easiest%20Way%20to%20Run%20Terraform%20in%20Visual%20Studio%20Code)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2023/04/01/the-easiest-way-to-run-terraform-in-visual-studio-code/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2023/04/01/the-easiest-way-to-run-terraform-in-visual-studio-code/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2023/04/01/the-easiest-way-to-run-terraform-in-visual-studio-code/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2023/04/01/the-easiest-way-to-run-terraform-in-visual-studio-code/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20The%20Easiest%20Way%20to%20Run%20Terraform%20in%20Visual%20Studio%20Code&body=https%3A%2F%2Fsrinimf.com%2F2023%2F04%2F01%2Fthe-easiest-way-to-run-terraform-in-visual-studio-code%2F&share=email)
-

### Like this:

Like Loading…