Skip to content

feat(aws): add AWS Lambda function #1044

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

Merged
merged 47 commits into from
Feb 8, 2024
Merged

Conversation

mogery
Copy link
Contributor

@mogery mogery commented Jan 26, 2024

Summary:
This PR adds the ability to run tailcall on AWS Lambda.

Issue Reference(s):
Fixes #874
/claim #874

To-do:

  • Implement configuration

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Jan 26, 2024
@mogery
Copy link
Contributor Author

mogery commented Jan 26, 2024

Implementation details:

  • Deployment to Lambda is done via Terraform.
    • The GraphQL definition is bundled with the image at deploy-time.
  • There's no built-in KV store for AWS like there is in Cloudflare, so I built a simple Cache provider based on HashMap.
  • The current implementation of LambdaFileIO reads from the filesystem, instead of, say, an S3 bucket, since it's needed to retrieve the GraphQL definition from the image bundle.

Questions:

Should the Terraform deployment code live in this repo?

The DX of a Lambda deployment is pretty bad right now. A dev has to:

  1. Install Rust, Terraform, Python and cargo-lambda
  2. Add AWS credentials to environment variables
  3. Clone this repo
  4. Build the lambda crate with cargo-lambda
  5. Write a GraphQL definition into lambda/deploy/config.graphql
  6. Run terraform init && terraform apply

We could move this to an external repo, and I can make the CI build Lambda images and put it in Releases, and the Terraform config can be adapted to download it. With that, the DX would be the following:

  1. Install Terraform
  2. Add AWS credentials to environment variables
  3. Clone that repo
  4. Write a GraphQL definition into lambda/deploy/config.graphql
  5. Run terraform init && terraform apply

This is, in my opinion, much better. It also lets devs fork the repo and manage their own deployment schema on GitHub.

@mogery mogery marked this pull request as ready for review January 26, 2024 18:17
@mogery
Copy link
Contributor Author

mogery commented Feb 1, 2024

Adapted to the new TargetRuntime.

@mogery mogery requested a review from meskill February 8, 2024 12:41
@mogery
Copy link
Contributor Author

mogery commented Feb 8, 2024

Screenshot 2024-02-08 at 21 00 45
...wtf are these codecov errors

@meskill
Copy link
Contributor

meskill commented Feb 8, 2024

Screenshot 2024-02-08 at 21 00 45 ...wtf are these codecov errors

yeah, strange, but don't bother about it, it won't affect pr merge

@meskill meskill changed the title feat: add AWS Lambda function feat(aws): add AWS Lambda function Feb 8, 2024
@meskill meskill merged commit 18147cc into tailcallhq:main Feb 8, 2024
@mogery mogery deleted the mog/lambda branch February 8, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support serverless via AWS Lambda
3 participants