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
DIAL(Did I Alert Lambda?) is a centralised security misconfiguration detection framework which completely runs on AWS Managed services like AWS API Gateway, AWS Event Bridge & AWS Lambda

DIAL(Did I Alert Lambda?) is a centralised security misconfiguration detection framework which completely runs on AWS Managed services like AWS API Gateway, AWS Event Bridge & AWS Lambda

CRED 71 Dec 29, 2022
Pyspark sam - Analyze Big Sequence Alignments with PySpark in AWS EMR

pyspark_sam This repo hosts my code for the article "Analyze Big Sequence Alignm

Sixing Huang 4 Dec 9, 2022
Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).

Backup and Recovery with AWS Backup This repository provides you with a management and deployment solution for implementing Backup and Recovery with A

AWS Samples 8 Nov 22, 2022
Automated AWS account hardening with AWS Control Tower and AWS Step Functions

Automate activities in Control Tower provisioned AWS accounts Table of contents Introduction Architecture Prerequisites Tools and services Usage Clean

AWS Samples 20 Dec 7, 2022
💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline!

LocalStack - A fully functional local AWS cloud stack LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. Cur

LocalStack 45.3k Jan 2, 2023
The AWS Lambda Serverless Blind XSS App

Ass The AWS Lambda Serverless Blind XSS App 利用VPS配置XSS平台太麻烦了,如果利用AWS的Lambda那不就是一个域名的事情么?剩下的环境配置、HTTPS证书、隐私性、VPS续费都不用管了, 所以根据xless重写了Lambda平台的XSS,利用sla

cocokey 2 Dec 27, 2021
Collection of AWS Fault Injection Simulator (FIS) experiment templates.

Collection of AWS Fault Injection Simulator (FIS) experiment templates. These templates let you perform chaos engineering experiments on resources (applications, network, and infrastructure) in the AWS Cloud.

Adrian Hornsby 8 Nov 27, 2022
Project template for using aws-cdk, Chalice and React in concert, including RDS Postgresql and AWS Cognito

What is This? This repository is an opinonated project template for using aws-cdk, Chalice and React in concert. Where aws-cdk and Chalice are in Pyth

Rasmus Jones 4 Nov 7, 2022
AWS Blog post code for running feature-extraction on images using AWS Batch and Cloud Development Kit (CDK).

Batch processing with AWS Batch and CDK Welcome This repository demostrates provisioning the necessary infrastructure for running a job on AWS Batch u

AWS Samples 7 Oct 18, 2022
Cookies is a project inspired by python cookiecutter but used for terraform generation.

Introduction Cookies is a project inspired by python cookiecutter but used for terraform generation. How to run your terraform After you download your

Digger 6 Mar 14, 2022
AWS Auto Inventory allows you to quickly and easily generate inventory reports of your AWS resources.

Photo by Denny Müller on Unsplash AWS Automated Inventory ( aws-auto-inventory ) Automates creation of detailed inventories from AWS resources. Table

AWS Samples 123 Dec 26, 2022
A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier

A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier

Amazon Web Services - Labs 1.9k Jan 7, 2023
Unauthenticated enumeration of services, roles, and users in an AWS account or in every AWS account in existence.

Quiet Riot ?? C'mon, Feel The Noise ?? An enumeration tool for scalable, unauthenticated validation of AWS principals; including AWS Acccount IDs, roo

Wes Ladd 89 Jan 5, 2023
Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir.

RUST USERBOT ???? Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir. Qurulum Heroku Serverə qurulum git clone https://github.com/rustres

null 1 Oct 25, 2021
Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance frameworks.

aws-allowlister Automatically compile an AWS Service Control Policy that ONLY allows AWS services that are compliant with your preferred compliance fr

Salesforce 189 Dec 8, 2022
SSH-Restricted deploys an SSH compliance rule (AWS Config) with auto-remediation via AWS Lambda if SSH access is public.

SSH-Restricted SSH-Restricted deploys an SSH compliance rule with auto-remediation via AWS Lambda if SSH access is public. SSH-Auto-Restricted checks

Adrian Hornsby 30 Nov 8, 2022
aws-lambda-scheduler lets you call any existing AWS Lambda Function you have in a future time.

aws-lambda-scheduler aws-lambda-scheduler lets you call any existing AWS Lambda Function you have in the future. This functionality is achieved by dyn

Oğuzhan Yılmaz 57 Dec 17, 2022
POC de uma AWS lambda que executa a consulta de preços de criptomoedas, e é implantada na AWS usando Github actions.

Cryptocurrency Prices Overview Instalação Repositório Configuração CI/CD Roadmap Testes Overview A ideia deste projeto é aplicar o conteúdo estudado s

Gustavo Santos 3 Aug 31, 2022