Scripts Documentation
Main Deployment Scripts
setup_classroom.sh - Master Deployment Script
Purpose: Main entry point for deploying or destroying classroom infrastructure.
Usage:
./scripts/setup_classroom.sh --name <classroom-name> --cloud [aws|azure] [OPTIONS]
Required Parameters:
--name: Name of the classroom (used for resource naming)--cloud: Cloud provider (awsorazure)
AWS Options:
--region: AWS region (default:eu-west-1)--environment: Environment name (dev,staging,prod, default:dev)--with-pool: Create EC2 instance pool for students--pool-size: Number of EC2 instances (default: 40)--workshop: Workshop identifier (default:testus_patronus)--only-common: Apply/destroy only the common stack--only-workshop: Apply/destroy only the workshop stack--skip-packaging: Skip Lambda packaging (use existing packages)
Common Options:
--destroy: Destroy infrastructure instead of creating--parallelism: Terraform parallelism (default: 4)--force-unlock: Force unlock Terraform state
Examples:
# Full deployment with EC2 pool
./scripts/setup_classroom.sh \
--name spring-2024 \
--cloud aws \
--region eu-west-1 \
--environment dev \
--with-pool \
--pool-size 20
# Lambda-only deployment
./scripts/setup_classroom.sh \
--name dev-test \
--cloud aws \
--region eu-west-1 \
--environment dev
# Destroy infrastructure
./scripts/setup_classroom.sh \
--name spring-2024 \
--cloud aws \
--region eu-west-1 \
--environment dev \
--destroy
package_lambda.sh - Lambda Function Packaging
Purpose: Packages Python Lambda functions with their dependencies into deployment-ready ZIP files.
Usage:
./scripts/package_lambda.sh --cloud [aws|azure]
What It Does:
- Creates Virtual Environment: Isolates Python dependencies
- Installs Dependencies: From
functions/aws/requirements.txtorfunctions/azure/requirements.txt - Packages Functions: Creates ZIP files with code + dependencies
- Validates Packages: Ensures all dependencies are included
Packaged Functions (AWS):
classroom_user_management.zip: Student account creationtestus_patronus_status.zip: Instance status checkingclassroom_stop_old_instances.zip: Cleanup automationclassroom_admin_cleanup.zip: Admin instance cleanupclassroom_instance_manager.zip: Core instance managementdify_jira_api.zip: Dify Jira API integration
Output Location:
functions/packages/
├── classroom_user_management.zip
├── testus_patronus_status.zip
├── classroom_stop_old_instances.zip
├── classroom_admin_cleanup.zip
├── classroom_instance_manager.zip
└── dify_jira_api.zip
build_frontend.sh - Frontend Build and Deployment
Purpose: Builds the React application and deploys it to S3/CloudFront.
Usage:
./scripts/build_frontend.sh [--environment dev] [--region eu-west-1]
What It Does:
- Installs Dependencies: Runs
npm installif needed - Builds React App: Creates production-optimized build
- Uploads to S3: Syncs files to S3 bucket with appropriate cache headers
- Invalidates CloudFront: Clears CDN cache for immediate updates
Options:
--environment: Environment name (default:dev)--region: AWS region (default:eu-west-3)
Note: Frontend deployment is normally handled automatically by setup_aws.sh during infrastructure deployment. Use this script for manual frontend updates.
Quick Start
For new deployments:
./scripts/setup_classroom.sh --name my-classroom --cloud aws --region eu-west-3
For local development:
./scripts/test_local.sh
For frontend-only updates:
./scripts/build_frontend.sh --environment dev --region eu-west-3
Notes
- All scripts use relative paths and can be run from the project root
- Terraform manages state automatically - no manual imports needed
- Frontend deployment is integrated into the main deployment flow
- Lambda packaging is automatic unless
--skip-packagingis used - For detailed deployment information, see the Deployment Guide
Clean Deployment Workflow
The deployment system is designed to work cleanly without manual state management:
- First deployment: Run
setup_classroom.sh- Terraform creates everything - Updates: Run
setup_classroom.shagain - Terraform updates existing resources - Clean slate: Use
--destroythen redeploy for a fresh start
No import scripts or state patching needed - Terraform handles it all.