AWS with Terraform

Download install Visual Studio Code


Download Visual Studio Code – Mac, Linux, Windows

Download and install AWS CLI

Run Visual Studio Code -> Install extension

Terraform, HashiCorp Terraform, Terraform Avanced Syntax Hightlighting

Download and install Terraform

( Copy Terraform.exe -> C:\Program Files\Terraform, add C:\Program Files\Terraform path in Windows System variables, reboot Windows)

Create AWS Account Secret Key

Create AWS account that have permission to create resource

Create Access Key ID and Secret Access Key (Choose Application running outside AWS)

Configure secret key for connecting to aws (using command AWS configure)

Start using Terraform

Check Terraform for more info: Docs overview | hashicorp/aws | Terraform Registry

– Start Visual Studio Code

– Create new folder to running terraform

– Create new terraform file (ex, with basic code below to create VPC

# Set provider as aws

terraform {
  required_providers {
    aws = {
        source = "hashicorp/aws"
        version = "~> 3.5.0"

# Set provider region

provider "aws" {
    region =  "us-west-2"


# This section to create VPC resource

resource "aws_vpc" "mytestvpc" { 
    cidr_block =  ""
    instance_tenancy =  "default"
    tags = { Name = "mytestvpc"}

In the terminal run command below just for initializing the folder

terraform init

To validate code formatting is correct

terraform validate

To check what will happen

terraform plan

To apply the change

terraform apply
when prompt type: yes


terraform.tfstats file the history of what change

To destroy what was create

Terraform destroy
when prompt type: yes