Docs/Tools/Local Test
Emulator

local_test.py

Starts the matching cloud emulator via Docker Compose, sets the correct environment variables, and runs terraform plan against the emulator to validate your infrastructure code without real cloud credentials or costs.

What it does

Checks if the emulator container is already running and starts it if not. Then sets the appropriate environment variables and runs terraform init + terraform plan pointed at the emulator endpoint.

CLI Usage
bash
python3 tools/local_test.py \
  --cloud aws \
  --terraform-dir ./my-app/terraform \
  --service payment-api
Emulators
CloudEmulatorDocker Compose file
awsLocalStack :4566tools/emulators/localstack.yml
azureAzurite :10000tools/emulators/azurite.yml
gcpFirestore (8080) + Pub/Sub (8085) :8080 / 8085tools/emulators/gcp-emulators.yml

Start an emulator manually before running the tool:

bash
# AWS
docker compose -f tools/emulators/localstack.yml up -d

# Azure
docker compose -f tools/emulators/azurite.yml up -d

# GCP
docker compose -f tools/emulators/gcp-emulators.yml up -d
AWS Environment Variables (Set Automatically)
AWS_ENDPOINT_URLhttp://localhost:4566
AWS_ACCESS_KEY_IDtest
AWS_SECRET_ACCESS_KEYtest
AWS_DEFAULT_REGIONus-east-1
Pro tip

Use tflocal (LocalStack's Terraform wrapper) instead of plain terraform for more accurate AWS emulation. Install with pip install terraform-local.

Next step: Cost Optimize →