Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUST-1253 Add AWS Lambda Examples #714

Merged

Conversation

isabelatkinson
Copy link
Contributor

Adds examples for using the driver with AWS Lambda. The examples are based off of this blog post and this example (thank you @pkdone!).

I've verified that these examples work by running them manually in Lambda.


#[cfg(feature = "aws-auth")]
mod auth;
mod no_auth;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are split into two separate modules to avoid including conditional compilation statements within the examples. Although we've talked about containing our examples in the top-level tests directory, I needed to include these ones here instead because the tests directory does not follow the module structure and therefore does not permit conditional compilation of an entire file.


// Runs a ping operation on the "db" database and returns the response.
async fn handler_create_client(_: LambdaEvent<Value>) -> Result<Value, lambda_runtime::Error> {
let uri = std::env::var("MONGODB_URI").unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our URI for the AWS auth tests is configured a little differently than what is done for MONGODB_CLIENT so this uses the URI set for the tests directly.

#[cfg_attr(feature = "tokio-runtime", tokio::test(flavor = "multi_thread"))]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_handler() {
if std::env::var("MONGODB_API_VERSION").is_ok() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A similar URI configuration issue -- it didn't seem super important to get versioned API coverage here so I just skipped the test.

@isabelatkinson isabelatkinson marked this pull request as ready for review August 8, 2022 19:29
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@isabelatkinson isabelatkinson merged commit bf10dbe into mongodb:main Aug 15, 2022
@isabelatkinson isabelatkinson deleted the aws-lambda-examples/RUST-1253 branch August 15, 2022 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants