Cookiecutter templates for Serverless applications using AWS SAM and the Rust programming language.

Overview

Cookiecutter SAM template for Lambda functions in Rust

This is a Cookiecutter template to create a serverless application based on the Serverless Application Model (SAM) and Rust.

It is important to note that you should not try to git clone this project but use SAM CLI instead as {{cookiecutter.project_slug}} will be rendered based on your input and therefore all variables and files will be rendered properly.

Usage

Generate a new SAM based Serverless App: sam init --location gh:aws-samples/cookiecutter-aws-sam-rust

You'll be prompted a few questions to help this cookiecutter template to scaffold this project and after its completed you should see a new folder at your current path with the name of the project you gave as input.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Comments
  • Error in DynamoDB Example

    Error in DynamoDB Example

    Is this still maintained? I'm getting this error in the DynamoDB PutItem example when testing through the API Gateway console:

    Error: fork/exec /var/task/bootstrap: exec format error","errorType":"Runtime.InvalidEntrypoint"}
    

    Full stack trace from API Gateway:

    Execution log for request 59510e51-00b4-4547-8f23-f2c78853f963
    Mon Oct 03 21:21:57 UTC 2022 : Starting execution for request: 59510e51-00b4-4547-8f23-f2c78853f963
    Mon Oct 03 21:21:57 UTC 2022 : HTTP Method: PUT, Resource Path: /1
    Mon Oct 03 21:21:57 UTC 2022 : Method request path: {id=1}
    Mon Oct 03 21:21:57 UTC 2022 : Method request query string: {}
    Mon Oct 03 21:21:57 UTC 2022 : Method request headers: {}
    Mon Oct 03 21:21:57 UTC 2022 : Method request body before transformations: {
     "test1": "value1"   
    }
    Mon Oct 03 21:21:57 UTC 2022 : Endpoint request URI: https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:125442796819:function:sam-app-PutFunction-MD0hHzsVxOTv/invocations
    Mon Oct 03 21:21:57 UTC 2022 : Endpoint request headers: {X-Amz-Date=20221003T212157Z, x-amzn-apigateway-api-id=6uivcf6lpa, Accept=application/json, User-Agent=AmazonAPIGateway_6uivcf6lpa, Host=lambda.us-west-2.amazonaws.com, X-Amz-Content-Sha256=1d99691a619dabb60c0fcee08eafe8ff258ce1304ba5a13eb371c3429931e78f, X-Amzn-Trace-Id=Root=1-633b5275-28f71d9f7732b28db3977d13, x-amzn-lambda-integration-tag=59510e51-00b4-4547-8f23-f2c78853f963, Authorization=*********************************************************************************************************************************************************************************************************************************************************************************************************************************************051ad3, X-Amz-Source-Arn=arn:aws:execute-api:us-west-2:125442796819:6uivcf6lpa/test-invoke-stage/PUT/{id}, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEPX//////////wEaCXVzLXdlc3QtMiJHMEUCIDvheHA57yK2cJKj/6o6OGLAZm6yP5iL0dJxpgs3VSgSAiEA/a+m25dgLmUbiaJRTr/QpNWyt+VLhdLfpfYmTs9Ml [TRUNCATED]
    Mon Oct 03 21:21:57 UTC 2022 : Endpoint request body after transformations: {"resource":"/{id}","path":"/1","httpMethod":"PUT","headers":null,"multiValueHeaders":null,"queryStringParameters":null,"multiValueQueryStringParameters":null,"pathParameters":{"id":"1"},"stageVariables":null,"requestContext":{"resourceId":"lkt395","resourcePath":"/{id}","httpMethod":"PUT","extendedRequestId":"ZcnSXE4EvHcFjGw=","requestTime":"03/Oct/2022:21:21:57 +0000","path":"/{id}","accountId":"125442796819","protocol":"HTTP/1.1","stage":"test-invoke-stage","domainPrefix":"testPrefix","requestTimeEpoch":1664832117342,"requestId":"59510e51-00b4-4547-8f23-f2c78853f963","identity":{"cognitoIdentityPoolId":null,"cognitoIdentityId":null,"apiKey":"test-invoke-api-key","principalOrgId":null,"cognitoAuthenticationType":null,"userArn":"arn:aws:sts::125442796819:assumed-role/AWSReservedSSO_AWSAdministratorAccess_7af6fb32ef239831/awsevan","apiKeyId":"test-invoke-api-key-id","userAgent":"aws-internal/3 aws-sdk-java/1.12.302 Linux/5.4.207-126.363.amzn2int.x86_64 OpenJDK_64-B [TRUNCATED]
    Mon Oct 03 21:21:57 UTC 2022 : Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:125442796819:function:sam-app-PutFunction-MD0hHzsVxOTv/invocations
    Mon Oct 03 21:21:57 UTC 2022 : Received response. Status: 200, Integration latency: 29 ms
    Mon Oct 03 21:21:57 UTC 2022 : Endpoint response headers: {Date=Mon, 03 Oct 2022 21:21:57 GMT, Content-Type=application/json, Content-Length=162, Connection=keep-alive, x-amzn-RequestId=4218581b-57b2-48be-9f2c-29beafb5354b, X-Amz-Function-Error=Unhandled, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-633b5275-28f71d9f7732b28db3977d13;sampled=1}
    Mon Oct 03 21:21:57 UTC 2022 : Endpoint response body before transformations: {"errorMessage":"RequestId: 4218581b-57b2-48be-9f2c-29beafb5354b Error: fork/exec /var/task/bootstrap: exec format error","errorType":"Runtime.InvalidEntrypoint"}
    Mon Oct 03 21:21:57 UTC 2022 : Lambda execution failed with status 200 due to customer function error: RequestId: 4218581b-57b2-48be-9f2c-29beafb5354b Error: fork/exec /var/task/bootstrap: exec format error. Lambda request id: 4218581b-57b2-48be-9f2c-29beafb5354b
    Mon Oct 03 21:21:57 UTC 2022 : Method completed with status: 502
    
    opened by ezeev 2
  • Runtime update to use TowerService service_fn

    Runtime update to use TowerService service_fn

    Issue #, if available:

    Description of changes:

    1. I have updated to the latest runtime that is using TowerService
    2. Makefile can use zigbuild for arm64
    3. Updated the readme

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by ymwjbxxq 0
  • feat: remove generic with DynConnector

    feat: remove generic with DynConnector

    Issue #, if available:

    Description of changes:

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by nmoutschen 0
  • feat: add DynamoDB template

    feat: add DynamoDB template

    Issue #, if available:

    Description of changes:

    Add a sample API that put items to DynamoDB

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by nmoutschen 0
  • fix: correctly set the architecture

    fix: correctly set the architecture

    Issue #, if available:

    Description of changes:

    Correctly set the CPU architecture when generating a new project.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by nmoutschen 0
  • fix: make the build target phony

    fix: make the build target phony

    Issue #, if available:

    Description of changes:

    Make the build target phony. As we uses the build folder for the Lambda function, running make build multiple time does nothing with make saying that the target is already up to date.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by nmoutschen 0
  • update API Gateway URL to support other AWS partitions

    update API Gateway URL to support other AWS partitions

    Issue #, if available:

    Description of changes:

    Use ${AWS::URLSuffix} to support other AWS partitions

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by bnusunny 0
  • fix: hello world test and fmt

    fix: hello world test and fmt

    Issue #, if available:

    Description of changes:

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by nmoutschen 0
  • chore: add CI for PRs

    chore: add CI for PRs

    Issue #, if available:

    Description of changes:

    Add automated cargo fmt, clippy, and build for each template.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by nmoutschen 0
  • Command /tmp/tmpx9b4ep7i.py not available

    Command /tmp/tmpx9b4ep7i.py not available

    What am I doing wrong?

    You've downloaded /home/user/.cookiecutters/cookiecutter-aws-sam-rust before. Is it okay to delete and re-download it? [yes]: n
    Do you want to re-use the existing version? [yes]:
    project_name [My Project]: userdata-rust-api
    project_slug [userdata-rust-api]:
    Select architecture:
    1 - x86_64
    2 - arm64
    Choose from 1, 2 [1]: 1
    Select template:
    1 - hello-world
    2 - put-dynamodb
    Choose from 1, 2 [1]: 2
    2022-10-15 22:49:27 Command /tmp/tmpx9b4ep7i.py not available
    Usage: sam [OPTIONS] COMMAND [ARGS]...
    

    Try again with some different options...

    You've downloaded /home/user/.cookiecutters/cookiecutter-aws-sam-rust before. Is it okay to delete and re-download it? [yes]:
    project_name [My Project]: userdata-rust-api
    project_slug [userdata-rust-api]:
    Select architecture:
    1 - x86_64
    2 - arm64
    Choose from 1, 2 [1]: 1
    Select template:
    1 - hello-world
    2 - put-dynamodb
    Choose from 1, 2 [1]: 1
    2022-10-15 22:52:13 Command /tmp/tmpohfvkpt_.py not available
    Usage: sam [OPTIONS] COMMAND [ARGS]...
    

    OS:

    $ uname -a
    Linux DESK 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    opened by refacktor 1
Owner
AWS Samples
AWS Samples
Ref Arch: Serverless GraphQL in Rust on AWS

A Whole Hog Reference Architecture for an Apollo Federation-Ready, Serverless, Rust-Based GraphQL Microservice on AWS using Cloud Development Kit (CDK)

Michael Edelman 3 Jan 12, 2022
Serverless search for AWS.

Pathery ?? Serverless Search ?? Pathery is a serverless search service built on AWS using Rust, CDK and Tantivy. ?? WARNING: This is currently a work

Tyler van Hensbergen 40 Jan 3, 2023
Adds SEQ and QUAL to secondary alignments from SAM/BAM/CRAM

secondary_rewriter Some aligners such as minimap2 do not write the SEQ and QUAL fields to secondary alignments (which are sometimes called multi-mappe

Colin Diesh 4 Oct 31, 2022
A simple workshop to learn how to write, test and deploy AWS Lambda functions using the Rust programming language

Rust Lambda Workshop Material to host a workshop on how to build and deploy Rust Lambda functions with AWS SAM and Cargo Lambda. Intro What is Serverl

Luciano Mammino 13 Mar 28, 2024
Rs.aws-login - A command line utility to simplify logging into AWS services.

aws-login A command line utility to simplify logging into AWS accounts and services. $ aws-login use ? Please select a profile to use: › ❯ dev-read

Kevin Herrera 11 Oct 30, 2022
Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications

Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications Explore PipeCD docs » Overview PipeCD provides a unified co

PipeCD 650 Dec 29, 2022
A tool to run web applications on AWS Lambda without changing code.

AWS Lambda Adapter A tool to run web applications on AWS Lambda without changing code. How does it work? AWS Lambda Adapter supports AWS Lambda functi

AWS Samples 321 Jan 2, 2023
Serverless setup for activity pub (using lambda+dynamodb) in Rust

Serverless ActivityPub About This is an experiment to have free/cheaper activitypub instances running on AWS (making use of free tiers as much as poss

Conrad Ludgate 3 Dec 30, 2022
A formal, politely verbose programming language for building next-gen reliable applications

vfpl Pronounced "Veepl", the f is silent A politely verbose programming language for building next-gen reliable applications Syntax please initialize

VFPL 4 Jun 27, 2022
This repo is a sample video search app using AWS services.

Video Search This repo is a sample video search app using AWS services. You can check the demo on this link. Features Transcribing Video and generate

AWS Samples 8 Jan 5, 2023
Examples of how to use Rust with Serverless Framework, Lambda, API Gateway v1 and v2, SQS, GraphQL, etc

Rust Serverless Examples All examples live in their own directories: project: there is nothing here, just a simple cargo new project_name with a custo

Fernando Daciuk 9 Dec 17, 2022
⚙️ A cute .gitignore generator with support for custom templates

Gign A Gitignore Generator Table of Contents Examples Install Custom templates Help Examples # This is how you going to use it probably most of the ti

Vadim 6 Dec 7, 2022
Better touch. Efficient file creation with templates.

touchx Better touch. Efficient file creation with templates. If you save files such as LICENSE or .editorconfig, you can create files with similar con

akameco 5 Apr 30, 2024
🚫📆 Serverless calendar built with shuttle.rs

zerocal ?? ?? Welcome to zerocal, the serverless calendar. It allows you to create calendar invites from the convenience of your terminal! ?? Here's m

Matthias 150 Jan 2, 2023
Monorep for fnRPC (high performance serverless rpc framework)

fnrpc Monorep for fnRPC (high performance serverless rpc framework) cli Cli tool help build and manage functions Create RPC functions Create & Manage

Faasly 3 Dec 21, 2022
Easy switch between AWS Profiles and Regions

AWSP - CLI To Manage your AWS Profiles! AWSP provides an interactive terminal to interact with your AWS Profiles. The aim of this project is to make i

KubeOps Skills 14 Dec 25, 2022
This repo scans pypi, rubygems and hexpm for AWS keys

What is this? This is a project to try to detect any AWS access keys that are accidentally uploaded to the Python Package Index (PyPi). New uploads ar

Tom Forbes 80 Jan 28, 2023
A lightweight distributed message queue. Like AWS SQS and RSMQ but on Postgres.

Postgres Message Queue (PGMQ) A lightweight distributed message queue. Like AWS SQS and RSMQ but on Postgres. Features Lightweight - Built with Rust a

Tembo 15 Jul 25, 2023
Rust client for AWS Infinidash service.

AWS Infinidash - Fully featured Rust client Fully featured AWS Infinidash client for Rust applications. You can use the AWS Infinidash client to make

Rafael Carício 15 Feb 12, 2022