Skip to content

An example of Python CDK v2 Construct for AWS Lambda in Rust using Function-url feature. Local tests with SAM.

License

Notifications You must be signed in to change notification settings

Sonic0/cdk-python-rust-lambda-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple example with CDK V2 Python and Rust.

Install & Deploy

Install AWS CDK CLI

npm install -g aws-cdk

Install pip dependencies (I suggest the use of a virtual env)

pip install -U -r requirements.txt

Build code with

rustup target add x86_64-unknown-linux-musl (only the first time)
./cdk-build.sh

Deploy Lambda

cdk deploy LambdaRustTestStack [--profile <local-aws-profile>]

Test Lambda

The request and response event formats follow the same schema as the Amazon API Gateway payload format version 2.0. For more information about AWS Lambda Function-Url, see AWS Lambda doc.

Locally (SAM)

./cdk-build.sh
cdk synth --no-staging > template.yml
sam local invoke LambdaRustTestXXXXXXX --event tests/lambda-function-url-input-example.json

Function url via curl

Get function url from deploy Output

Input

curl -X POST -H "Content-Type: application/json" -d '{"message": "I love you, Nana", "name": "Hachiko" }' <function-url>

Output

{
  "response": "Hello, Hachiko! Your message is: I love you, Nana"
}

About

An example of Python CDK v2 Construct for AWS Lambda in Rust using Function-url feature. Local tests with SAM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published