DEV Community

Samuel Udeh
Samuel Udeh

Posted on

Step-by-Step Guide to Setting Up Terraform, AWS CLI, and VS Code

A Step-by-Step Guide to Setting Up Terraform, AWS CLI, and VS Code. Whether you’re a beginner or looking to refresh your setup, this guide will walk you through installing Terraform, configuring the AWS CLI, and setting up VS Code for smooth Infrastructure as Code (IaC) workflows.

Installing Terraform:

On Windows:

Download the Terraform binary from Terraform’s official website.
Extract the binary to a directory (e.g., C:\Terraform).
Add the directory to your system’s PATH:
Open System Properties > Environment Variables.
Edit the PATH variable and add C:\Terraform.

Image description

On macOS/Linux:
Install using a package manager

Image description

Verify installation:

terraform version

Set Up the AWS CLI
The AWS CLI allows Terraform to communicate with AWS for provisioning resources.

Installation:
1.Download the AWS CLI from AWS CLI Installation Guide.
2.Follow the installation steps for your OS.

Image description

Verify AWS CLI

Image description

Configuration
Run the following command to configure the CLI:

aws configure

Provide your Access Key ID, Secret Access Key, Region, and output format (e.g., json).

Test the configuration:
use the command "aws s3 ls"
If this works, your AWS CLI is ready to go!

Install and Configure VS Code

VS Code is a lightweight and powerful editor perfect for Terraform projects.

Installation
Download VS Code from VS Code's website.

Install Terraform extensions:

Open VS Code.
Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X).
Search for and install "HashiCorp Terraform".
Optional Extensions for Productivity
AWS Toolkit: For managing AWS services directly from VS Code.
Prettier: For consistent formatting of your Terraform code.

Top comments (0)