Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions bin/deploy-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ ENVIRONMENT_CONFIG="$PROJECT_ROOT/ENVIRONMENT.config"
INFRA_DIR="$PROJECT_ROOT/infra"
ENVIRONMENT=${1:-"aws"}

# Select terraform command (terraform or tflocal)
TF_CMD="terraform"

# Set up PATH and AWS region
export PATH="$HOME/.local/bin:$PATH"
export AWS_REGION=${AWS_REGION:-us-east-1}
Expand All @@ -77,31 +74,27 @@ if [ "$ENVIRONMENT" = "aws" ]; then
fi
else
# Local development configuration
if command -v tflocal > /dev/null 2>&1; then
echo "INFO: Using local development (tflocal)..."
TF_CMD="tflocal"
else
echo "INFO: Using local development (terraform with AWS_ENDPOINT override)..."
export AWS_ENDPOINT_URL="http://localhost:4566"
fi
export AWS_ENDPOINT_URL="http://localhost:4566"
export AWS_ENDPOINT_URL_S3="http://s3.localhost.localstack.cloud:4566"

# Set dummy AWS credentials for local development
#export AWS_ACCESS_KEY_ID=test
#export AWS_SECRET_ACCESS_KEY=test
BUCKET_NAME="coding-workshop-tfstate-${PARTICIPANT_ID:-abcd1234}"
if ! aws s3 ls | grep -q "$BUCKET_NAME"; then
aws s3 mb "s3://$BUCKET_NAME"
fi
fi

# Initialize Terraform with backend configuration
if [ -n "$PARTICIPANT_ID" ] && [ "$TF_CMD" = "terraform" ]; then
if [ -n "$PARTICIPANT_ID" ]; then
echo "INFO: Using custom backend configuration..."
$TF_CMD init -reconfigure -backend-config="bucket=coding-workshop-tfstate-${PARTICIPANT_ID:-abcd1234}" -backend-config="region=${AWS_REGION:-us-east-1}"
terraform init -reconfigure -backend-config="bucket=coding-workshop-tfstate-${PARTICIPANT_ID:-abcd1234}" -backend-config="region=${AWS_REGION:-us-east-1}"
else
echo "WARNING: No backend.config found. Using default backend configuration."
echo "INFO: For multi-participant workshops, run: ./bin/setup-participant.sh"
$TF_CMD init -reconfigure
terraform init -reconfigure
fi

# Apply Terraform configuration automatically
$TF_CMD apply -auto-approve
terraform apply -auto-approve
echo "INFO: Infrastructure deployment complete!"

# Display API endpoint
Expand Down
20 changes: 10 additions & 10 deletions bin/setup-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ run_preflight_checks() {
install_prerequisites() {
print_section "System Prerequisites"

local packages="ca-certificates curl gnupg lsb-release apt-transport-https"
local packages="ca-certificates curl python3-pip gnupg lsb-release apt-transport-https"
packages="$packages software-properties-common unzip wget jq"

if [ "$INSTALL_DNSMASQ" = true ]; then
Expand Down Expand Up @@ -1773,16 +1773,15 @@ main() {

# Install everything
install_prerequisites
install_python "3.11"
install_python "3.12"
install_python "3.13"
install_python "3.14"
install_vscode
install_intellij
install_pycharm
install_chrome
install_docker
install_terraform
install_awscli
install_localstack
install_tflocal
install_awslocal
install_postgres "$POSTGRES_VERSION"
configure_postgres_auth
install_pgadmin
Expand All @@ -1791,10 +1790,11 @@ main() {
configure_mongodb_auth
install_mongodb_compass
install_nodejs
install_python "3.14"
install_python "3.13"
install_python "3.12"
install_python "3.11"
install_terraform
install_awscli
install_localstack
install_tflocal
install_awslocal
configure_dnsmasq

# Verification and summary
Expand Down
24 changes: 19 additions & 5 deletions bin/start-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,20 @@ echo -e " ✓ Docker is running"
# Check if LocalStack is running
LOCALSTACK_OK=false
if curl -s http://localhost:4566/_localstack/health > /dev/null 2>&1; then
LOCALSTACK_OK=true
echo -e " ✓ LocalStack is running"
else
# Verify the correct image is running
RUNNING_IMAGE=$(docker inspect localstack-main --format '{{.Config.Image}}' 2>/dev/null || echo "")
if [ "$RUNNING_IMAGE" != "$LOCALSTACK_IMAGE" ]; then
echo -e " ⚠ LocalStack running with wrong image ($RUNNING_IMAGE), expected $LOCALSTACK_IMAGE. Restarting..."
localstack stop
docker stop localstack-main 2>/dev/null || true
sleep 5
else
LOCALSTACK_OK=true
echo -e " ✓ LocalStack is running ($LOCALSTACK_IMAGE)"
fi
fi

if [ "$LOCALSTACK_OK" = false ]; then
# Check if LocalStack docker container is already running
if docker ps | grep -q localstack-main; then
echo -e " ⚠ Stopping existing LocalStack container..."
Expand Down Expand Up @@ -260,10 +271,12 @@ fi
# Detect MongoDB host for LocalStack Lambda functions
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export TF_VAR_mongodb_host="172.17.0.1"
echo -e " Detected Linux - using MongoDB host: 172.17.0.1"
export TF_VAR_aws_postgres_host="172.17.0.1"
echo -e " Detected Linux - using host: 172.17.0.1"
else
export TF_VAR_mongodb_host="host.docker.internal"
echo -e " Detected Mac/Windows - using MongoDB host: host.docker.internal"
export TF_VAR_aws_postgres_host="host.docker.internal"
echo -e " Detected Mac/Windows - using host: host.docker.internal"
fi

# Change to infrastructure directory
Expand Down Expand Up @@ -382,6 +395,7 @@ echo "============================================================"
echo ""
echo "Services Status:"
echo " • MongoDB: Running on 0.0.0.0:27017"
echo " • PostgreSQL: Running on localhost:5432"
echo " • LocalStack: Running on localhost:4566"
echo " • Backend: Deployed to LocalStack"
echo " • Proxy: Running on localhost:3001"
Expand Down
6 changes: 6 additions & 0 deletions infra/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ variable "aws_mongo_host" {
type = string
default = null
}

variable "aws_postgres_host" {
description = "PostgreSQL host for LocalStack. Defaults to 'host.docker.internal' (on Linux, set to '172.17.0.1')."
type = string
default = null
}
Loading