1+ #! /usr/bin/env bash
2+ # Quick start local integration with LocalStack + Terraform + Docker services
3+ # Usage: ./scripts/localstack-quickstart.sh
4+
5+ set -euo pipefail
6+ cd " $( dirname " $( realpath " $0 " ) " ) /.."
7+
8+ check_cmd () { command -v " $1 " > /dev/null 2>&1 || { echo " Required command '$1 ' not found. Install it and retry." ; exit 2; } }
9+
10+ check_cmd docker
11+ check_cmd terraform
12+ check_cmd aws
13+ check_cmd docker-compose || true
14+
15+ echo " 1/5 Starting LocalStack..."
16+ cd localstack
17+ docker compose down -v || true
18+ docker compose up -d
19+ sleep 15
20+
21+ echo " 2/5 Applying infra (terraform)..."
22+ cd ../infra
23+ rm -rf .terraform* terraform.tfstate* || true
24+ terraform init -input=false
25+ terraform apply -var-file=dev.tfvars -auto-approve
26+
27+ echo " 3/5 Building and running order-api..."
28+ cd ../order-api
29+ docker build -t order-api .
30+
31+ SQS_QUEUE_URL=$( cd ../infra && terraform output -raw sqs_queue_url)
32+ DDB_TABLE=$( cd ../infra && terraform output -raw dynamodb_table_name)
33+ export AWS_ENDPOINT_URL=" http://host.docker.internal:4566"
34+
35+ docker rm -f order-api 2> /dev/null || true
36+ docker run -d --name order-api -p 8000:8000 \
37+ -e SQS_QUEUE_URL=" $SQS_QUEUE_URL " \
38+ -e DDB_TABLE=" $DDB_TABLE " \
39+ -e AWS_ENDPOINT_URL=" $AWS_ENDPOINT_URL " \
40+ order-api
41+
42+ echo " 4/5 Building and running order-processor..."
43+ cd ../order-processor
44+ go mod tidy
45+ docker build -t order-processor .
46+
47+ HOST_PORT=${HOST_PORT:- 9091}
48+ docker rm -f order-processor 2> /dev/null || true
49+ docker run -d --name order-processor -p ${HOST_PORT} :9090 \
50+ -e SQS_QUEUE_URL=" $SQS_QUEUE_URL " \
51+ -e DDB_TABLE=" $DDB_TABLE " \
52+ -e AWS_ENDPOINT_URL=" $AWS_ENDPOINT_URL " \
53+ order-processor
54+
55+ echo " Done. Services running:"
56+ echo " - Order API: http://localhost:8000"
57+ echo " - Processor metrics/health: http://localhost:${HOST_PORT} "
58+ echo " Tip: run ./scripts/smoke.sh to verify end-to-end."
0 commit comments