Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: how to run in aws lambda #87

Merged
merged 9 commits into from Dec 14, 2022
Merged

feat: how to run in aws lambda #87

merged 9 commits into from Dec 14, 2022

Conversation

tom-fletcher
Copy link
Contributor

In this PR:

A guide on how to run the turborepo-remote-cache server in an AWS Lambda Function.

Credit to @cpitt for a starting point on the handler code in #28.

This is dependant on #86 - as this change is required to allow the Lambda's temporary credentials to access the S3 bucket.

Issues reference:

@fox1t
Copy link
Collaborator

fox1t commented Dec 13, 2022

This is amazing. I think we can make it even easier! Would you mind adding a new entry point for the application inside /src folder? The same as we did for Vercel which has its own vercel.ts. At that point, there will be no need to force users to write their own Lambda proxy logic..

@matteovivona matteovivona self-assigned this Dec 13, 2022
@matteovivona matteovivona added the documentation Improvements or additions to documentation label Dec 13, 2022
@matteovivona matteovivona self-requested a review December 13, 2022 10:00
@matteovivona
Copy link
Collaborator

@all-contributors add @tom-fletcher for doc

@allcontributors
Copy link
Contributor

@tehkapa

I've updated the pull request to add @tom-fletcher! 🎉

@tom-fletcher
Copy link
Contributor Author

tom-fletcher commented Dec 13, 2022

@fox1t I'll have a look at this tomorrow my time. Vercel is a lot more graceful - with Lamba there is no remote build step (so there will always have to be some handler code manually written), but perhaps the logic can be moved into the library so it looks something like this:

import { lambdaHandler } from 'turborepo-remote-cache/lambdaHandler';

export const handler = lambdaHandler;

@tom-fletcher
Copy link
Contributor Author

Following changes have been made:

  • Moved the "Running in AWS Lambda" docs to live under "Deployment environments" as this is more consistent with existing docs
  • Moved the logic for the AWS Lambda Function into src/aws-lambda.ts and updated the docs. I've also added an example of how to create a bundle with esbuild to help get anyone who hasn't done this before started

While I was there, I also added an additional update to the docs to include information on how to use local environment variables to configure turbo, as an alternative to adding a config.json. I thought it easier to include in this PR, so it all can be reviewed in one go.

Using these env vars can be useful if you don't want to hard-code your apiUrl (for example if this is has been provisioned from an IaC provider such as Terraform or Pulumi), and want to pass configuration in via GitHub Actions or Codespaces secrets.

@matteovivona matteovivona added the enhancement New feature or request label Dec 14, 2022
Copy link
Collaborator

@fox1t fox1t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fox1t fox1t merged commit 936a4df into ducktors:main Dec 14, 2022
@matteovivona matteovivona added this to the v1.x.x milestone Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants