This is a step by step guide to deploying the Turborepo Remote Cache API on AWS and configuring a turborepo project to use it.
- Scaffold a new cdk app which uses the remote cache construct using the template:
degit aryasaatvik/turbo-remote-cache-aws/apps/template turbo-remote-cache
- Install dependencies using your preferred package manager. I recommend using pnpm
pnpm install
- Set the
TURBO_TOKEN
environment variable to a valid turbo token. You can generate a token usingopenssl rand -base64 32
.
echo "TURBO_TOKEN=$(openssl rand -base64 32)" >> .env
- Bootstrap the cdk app
pnpm cdk bootstrap
- Deploy the cdk app
pnpm cdk deploy
- The API will be deployed and you can find the endpoint in the outputs section of the cdk stack.
TurboRemoteCacheStack.TurboRemoteCacheAPIGatewayTurboRemoteCacheApiEndpoint
. This will be the value of theapiUrl
in the next step.
- Add the following to your turbo.json
{
"remoteCache": {
"enabled": true,
"apiUrl": "<your-api-url>",
}
}
-
TURBO_TEAM
environment variable needs to be set for the remote cache to work. This is also used as a prefix for S3 keys. You can either set it inline for unix based systems or use dotenv if you need cross platform support. -
You also need to set the
TURBO_TOKEN
environment variable to the same value as the one you set in the cdk stack. This can either be provided using--token="..."
or by setting the environment variable in your shell.
- Install dotenv
pnpm add -D dotenv
- Create a
.env
file in the root of your repo and add the following:
TURBO_TEAM=team
TURBO_TOKEN=...
- Add the following to your
package.json
scripts
"scripts": {
"build": "dotenv -- pnpm turbo run build"
}
- Verify that the remote cache works
pnpm build
TURBO_TEAM=team TURBO_TOKEN=... pnpm turbo run build