Infrastructure as Code for Smalruby APIs using AWS SAM (Serverless Application Model).
This repository contains AWS SAM templates and related infrastructure configurations for managing Smalruby APIs, including:
- cors-proxy: General-purpose proxy for various URLs with CORS issues
- scratch-api-proxy: Proxy for calling Scratch APIs that cannot be called directly due to CORS restrictions
- mesh-zone: Generate identity from gateway IPv4 address for Smalruby Mesh
template.yaml: Main SAM template defining API Gateway and Lambda functionslambda/: Lambda function source code directoriesscripts/: Deployment and utility scriptsexported-configs/: Exported configurations from existing AWS resourcessamconfig.toml: SAM configuration file
- smalruby-cors-proxy: General-purpose CORS proxy
- smalruby-mesh-zone-get: Mesh zone domain generation
- smalruby-scratch-api-proxy-translate: Scratch translate API proxy
- smalruby-scratch-api-proxy-get-project-info: Scratch project info API proxy
- cors-for-smalruby: CORS handler for Smalruby
- AWS CLI configured with appropriate credentials
- SAM CLI installed
- Ruby 3.4 runtime (for local testing)
# macOS
brew install aws-sam-cli
# Or pip
pip install aws-sam-cliローカルでLambda関数をテストするには、LOCAL_TESTING.mdを参照してください。
# 個別の関数をテスト
./test-local.sh CorsForSmalrubyFunction
# すべての関数をテスト
./test-all-local.sh
# ローカルAPI Gatewayを起動
./start-local-api.sh
# API エンドポイントをテスト
./test-api-endpoints.sh./scripts/export-config.sh# Build the application
sam build
# Start local API for testing
./scripts/local-test.sh
# or
sam local start-api
# Test specific function
sam local invoke SmalrubyCorsProxyFunction --event events/cors-proxy-event.json# Deploy to AWS
./scripts/deploy.sh
# or
sam build && sam deployAfter deployment, the following endpoints will be available:
GET /cors-proxy- General CORS proxyGET /mesh-domain- Mesh zone domain generationGET /scratch-api-proxy/translate- Scratch translate proxyGET /scratch-api-proxy/projects/{projectId}- Scratch project info proxy
- Stack Name:
smalruby-infrastructure - Region:
ap-northeast-1(Tokyo) - Stage:
prod - Domain:
api.smalruby.app
- Lambda functions are currently placeholder implementations
- Actual function code should be retrieved from existing Lambda functions
- All functions use Ruby 3.4 runtime with ARM64 architecture
- CORS headers are configured for cross-origin requests