Storage Service Example
This example shows how to deploy a storage service with scheduled cleanup jobs using cron expressions, multiple resource usage (S3 + MongoDB), and automated cleanup operations.
Configuration
- Type: Lambda single-image deployment
- Template: Uses
lambda-eutemplate from parent stack - Timeout: 120 seconds, 512MB memory
- Resources: Object storage (S3) + MongoDB integration
- Scheduling: Automated hourly cleanup jobs
Key Features
- Scheduled Jobs: Cron-based cleanup automation with
cron(0 * * * ? *) - Multiple Resource Usage: Both S3 storage and MongoDB
- Automated API Calls: Scheduled cleanup with Bearer token authentication
- Response Streaming:
RESPONSE_STREAMfor real-time processing feedback - Function URL: Direct HTTP access for manual operations
Scheduled Cleanup
The service automatically runs cleanup every hour:
lambdaSchedules:
- name: cleanup
expression: "cron(0 * * * ? *)" # every hour
request: # Automated POST request to /api/cleanup
Environments
- Staging:
staging-storage-service.example.com
Resource Usage
- Object Storage: S3 bucket for file storage
- MongoDB: Metadata and indexing storage
- Proxy Service: External storage proxy integration
Authentication
- Bearer Token: API key authentication for scheduled jobs
- Headers:
Authorization: Bearer ${secret:staging-storage-service-api-key}
Usage
- Ensure your parent stack provides object storage and MongoDB resources
- Configure API keys for authentication
- Set up storage proxy URL if using external storage
- Deploy and monitor cleanup job execution
- Check logs for automated cleanup operations
Parent Stack Requirements
This example requires a parent stack that provides:
lambda-eutemplate with scheduling supportobject-storageresource (S3 bucket)mongodbresource for metadata- Lambda deployment with cron scheduling
- Secrets management for API keys
Monitoring
- Request Debug: Enabled in staging for troubleshooting
- Cleanup Logs: Monitor hourly cleanup job execution
- Storage Metrics: Track storage usage and cleanup effectiveness