Easily deploy a barebones Typescript client app with a Lambda backend and S3 Bucket that can run jobs in a Docker container on AWS Batch with Fargate.
Features
- Live serverless development and one line deployment with SST
- Vanilla Typescript ready client, built with Vite
- Run your processing scripts locally with ESbuild.
- Optional project wide type validation using Zod
- Pre-configured
BatchConstruct
for managing Batch resources - Optional basic authentication and Airtable utilities
Motivation
Sometimes all you need is some simple UI and the ability to run scripts that take more than 15 minutes to complete without leaving your laptop running. I found that embedding an Airtable base into a webpage while using AWS Batch for processing is a simple and effective way of achieving this.
Make sure you have installed and configured the AWS CLI. You might find this guide helpful if you're new to serverless development. You may also want to install Docker.
Name your stack in the sst.json
file. Rename .example.env
file in the root to .local.env
and populate it it with your credentials. Because the client is publicly exposed, basic authentication is provided via the Token
input, which matches against the CLIENT_TOKEN
environment variable in the lambda handler to prevent unauthorised users submitting jobs.
Install the dependencies with yarn:
> yarn
Develop locally with the debug stack by running the client and services processes separately:
> yarn start:services
> yarn start:client
You can also run services/process.ts
locally by running yarn start:script
.
Watch and build shared types package:
> yarn tsc --watch
And when you're ready, deploy with:
> yarn deploy
You may periodically want to prune dangling docker images generated by AWS CDK. You can also build and run the docker container locally with the following commands:
# Build
> yarn docker:build
# Run
> yarn docker:run
When using the Airtable utility, you may want to update the Entry type in services/lib/airtable.ts
to reflect your column types. You may also want to uncomment the iframe code in client/index.html
and update the src
property with the iframe url for your table. Note that Airtable doesn't automatically update when loaded inside an iframe so a refresh button is provided. The iframe is also programatically refreshed when data is submitted.
- https://docs.sst.dev/
- https://sst.dev/guide.html
- https://docs.sst.dev/constructs
- https://docs.aws.amazon.com/batch/latest/userguide/job_queues.html
- https://docs.aws.amazon.com/batch/latest/userguide/job_definition_parameters.html
- https://github.com/aws-samples/aws-cdk-deep-learning-image-vector-embeddings-at-scale-using-aws-batch