Terraform VSCode Extension: Syntax Highlighting, Autocomplete, and Formatting
Install and configure the HashiCorp Terraform VSCode extension. Enable syntax highlighting, autocomplete, format on save, validation
Cloud Computing
Use LocalStack with Terraform to test AWS infrastructure locally. Create S3 buckets, DynamoDB tables, and Lambda functions without AWS costs or credentials.
Install LocalStack via Docker, point the AWS provider endpoints to http://localhost:4566, and run terraform apply. Your Terraform code works identically — but everything runs locally with zero AWS costs.
LocalStack emulates AWS services on your laptop. It supports 70+ services including S3, DynamoDB, Lambda, SQS, SNS, IAM, and API Gateway. Free tier covers most core services; Pro adds advanced services like ECS, EKS, and RDS.
# Docker Compose (recommended)
cat > docker-compose.yml << 'EOF'
version: "3.8"
services:
localstack:
image: localstack/localstack:latest
ports:
- "4566:4566"
environment:
- SERVICES=s3,dynamodb,lambda,sqs,sns,iam
- DEBUG=0
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
EOF
docker-compose up -d# Or via pip
pip install localstack
localstack startprovider "aws" {
region = "us-east-1"
access_key = "test"
secret_key = "test"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
endpoints {
s3 = "http://localhost:4566"
dynamodb = "http://localhost:4566"
lambda = "http://localhost:4566"
sqs = "http://localhost:4566"
sns = "http://localhost:4566"
iam = "http://localhost:4566"
}
}resource "aws_s3_bucket" "data" {
bucket = "my-test-bucket"
}
resource "aws_dynamodb_table" "sessions" {
name = "sessions"
billing_mode = "PAY_PER_REQUEST"
hash_key = "SessionID"
attribute {
name = "SessionID"
type = "S"
}
}
resource "aws_sqs_queue" "tasks" {
name = "task-queue"
visibility_timeout_seconds = 30
message_retention_seconds = 86400
}terraform init
terraform apply # Creates everything locally — no AWS account neededUse Terraform workspaces or variables to toggle:
variable "use_localstack" {
type = bool
default = false
}
locals {
endpoint = var.use_localstack ? "http://localhost:4566" : null
}
provider "aws" {
region = "us-east-1"
dynamic "endpoints" {
for_each = var.use_localstack ? [1] : []
content {
s3 = local.endpoint
dynamodb = local.endpoint
lambda = local.endpoint
}
}
skip_credentials_validation = var.use_localstack
skip_metadata_api_check = var.use_localstack
skip_requesting_account_id = var.use_localstack
}# Local testing
terraform apply -var="use_localstack=true"
# Deploy to real AWS
terraform apply -var="use_localstack=false"# Point AWS CLI to LocalStack
export AWS_ENDPOINT_URL=http://localhost:4566
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
export AWS_DEFAULT_REGION=us-east-1
aws s3 ls
aws dynamodb list-tables
aws sqs list-queues| Service | Status | Notes |
|---|---|---|
| S3 | ✅ Full | Buckets, objects, versioning |
| DynamoDB | ✅ Full | Tables, indexes, streams |
| SQS | ✅ Full | Standard and FIFO queues |
| SNS | ✅ Full | Topics, subscriptions |
| Lambda | ✅ Full | Functions, layers |
| IAM | ✅ Partial | Users, roles, policies |
| CloudFormation | ✅ Partial | Stack operations |
| API Gateway | ✅ Partial | REST APIs |
LocalStack + Terraform is the fastest way to develop and test AWS infrastructure locally. Point provider endpoints to localhost:4566, use fake credentials, and run the same Terraform code you'd use in production. Zero cost, instant feedback, no AWS account needed for development.
Install and configure the HashiCorp Terraform VSCode extension. Enable syntax highlighting, autocomplete, format on save, validation
Learn how to use Terraform data sources to query existing resources, look up AMIs, reference remote state, and build dynamic configurations. Complete.
Learn terraform taint, terraform untaint, and the modern terraform apply -replace. When to force-recreate resources, with examples for AWS EC2, modules
Configure Terraform S3 backend for remote state storage with DynamoDB state locking. Complete setup guide with IAM permissions, encryption, and versioning.