A simple example with CDK V2 Python and Rust.
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>]
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.
./cdk-build.sh
cdk synth --no-staging > template.yml
sam local invoke LambdaRustTestXXXXXXX --event tests/lambda-function-url-input-example.json
Get function url from deploy Output
curl -X POST -H "Content-Type: application/json" -d '{"message": "I love you, Nana", "name": "Hachiko" }' <function-url>
{
"response": "Hello, Hachiko! Your message is: I love you, Nana"
}