Testing and mocking applications built with the AWS Rust Lambda Runtime and the AWS Rust SDK

448 views Asked by At

I'm currently trying to build a simple Lambda that connects to Dynamo DB with AWS Rust Lambda Runtime and the AWS Rust SDK. My basic example works on AWS, but I'm keen to be able to perform manual tests and unit tests offline.

The main problem I can see, is in how I mock calls to and responses made via the AWS SDK. I'm also using Cargo Lambda which includes a test server command (cargo watch), but can it be set up to mock AWS SDK calls?

1

There are 1 answers

1
David Calavera On

The AWS SDK includes some mocking utilities that you can use to write integration tests for your code. You can see examples for mocking the CloudWatch API here:

https://github.com/calavera/cloudwatch_logs_processor/blob/main/src/cloudwatch_logs.rs#L134

You'll have to modify that to match DynamoDB targets, and endpoints, but the premise is the same.