#!/bin/bash # Caltrans Payment Tracking API - AWS Lambda Deployment Script # This script deploys the FastAPI application to AWS Lambda using SAM set -e # Exit on any error echo "🚀 Starting deployment of Caltrans Payment Tracking API to AWS Lambda..." # Check if SAM CLI is installed if ! command -v sam &> /dev/null; then echo "❌ SAM CLI is not installed. Please install it first:" echo " https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html" exit 1 fi # Check if AWS CLI is configured if ! aws sts get-caller-identity &> /dev/null; then echo "❌ AWS CLI is not configured. Please run 'aws configure' first." exit 1 fi # Build the SAM application echo "📦 Building SAM application..." sam build # Deploy the application echo "🚀 Deploying to AWS Lambda..." sam deploy --guided echo "✅ Deployment completed successfully!" echo "🌐 Your API is now available at the URL shown above." echo "" echo "📋 Available endpoints:" echo " GET / - API information" echo " GET /health - Health check" echo " GET /contracts/{contract_number}/payments - Get contract payments" echo " GET /contracts/{contract_number}/payments/monthly/{month} - Get monthly detailed payments" echo "" echo "📝 Example usage:" echo " curl https://your-api-url/contracts/033F0704/payments" echo " curl https://your-api-url/contracts/033F0704/payments/monthly/2024-12"