Deploy to AWS
Learn how to deploy your tsc.run applications to Amazon Web Services (AWS).
Prerequisites
Before deploying to AWS, ensure you have:
- AWS account with appropriate permissions
- AWS CLI installed and configured
- tsc.run CLI installed in your project
AWS setup
Install AWS CLI
# macOS
brew install awscli
# Linux
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# Windows
# Download from https://aws.amazon.com/cli/
Configure credentials
For local development:
# Configure with your AWS credentials
aws configure
# Or set environment variables
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_DEFAULT_REGION=us-east-1
For GitHub Actions deployment, OIDC authentication is recommended over access keys for security. While you can use access keys, OIDC provides more secure, temporary credentials without storing long-lived secrets.
Learn more:
Verify configuration
# Test AWS access
aws sts get-caller-identity
Deployment configuration
Configure your application for AWS deployment:
// tsc-run.config.js
export default {
provider: 'aws',
region: 'eu-west-2',
};
Deployment process
1. Set required environment variables
tsc.run uses AWS CDK under the hood and requires these environment variables:
export CDK_DEFAULT_ACCOUNT=123456789012 # Your AWS account ID
export CDK_DEFAULT_REGION=us-east-1 # Your preferred region
2. Build your application
tsc-run build
This creates optimised JavaScript bundles in the dist/
directory.
3. Deploy to AWS
tsc-run deploy
On first deployment, this will bootstrap your AWS account for CDK usage.
The deployment process:
- Bootstraps CDK (first deployment only)
- Creates Lambda functions for your API routes and subscribers.
- Sets up EventBridge for event routing.
- Configures API Gateway for HTTP routing.
- Creates IAM roles with appropriate permissions.
- Sets up CloudWatch for logging.
3. Get your API URL
After deployment, you'll receive your API Gateway URL:
Deployment successful!
API URL: https://abc123.execute-api.us-east-1.amazonaws.com/prod
Next steps
- Learn about Configuration options
- Explore Framework API for implementation
- Check Validation for request handling