AWS .NET Core 3.1 Mock Lambda Test Tool - How to set up 2 or more functions for local testing
Asked Answered
P

2

7

So I have a very simple aws-lambda-tools-defaults.json in my project:

{
  "profile": "default",
  "region": "us-east-2",
  "configuration": "Release",
  "framework": "netcoreapp3.1",
  "function-runtime": "dotnetcore3.1",
  "function-memory-size": 256,
  "function-timeout": 30,
  "function-handler": "LaCarte.RestaurantAdmin.EventHandlers::LaCarte.RestaurantAdmin.EventHandlers.Function::FunctionHandler"
}

It works, I can test my lambda code locally which is great. But I want to be able to test multiple lambdas, not just one. Does anyone else know how to change the JSON so that I can run multiple lambdas in the mock tool?

Thanks in advance,

Pejsach answered 23/4, 2021 at 3:2 Comment(0)
H
2

Simply remove the function-handler attribute from your aws-lambda-tools-defaults.json file and add a template attribute referencing your serverless.template (the AWS CloudFormation template used to deploy your lambda functions to your AWS cloud environment)

{
    ...
    "template": "serverless.template"
    ...
}

Then, you can test you lambda function locally for example with The AWS .NET Mock Lambda Test Tool. So now you'll see the Function dropdown List has changed from listing the lambda function name you specified in your function-handler

to the list of lambda functions declared in your serverless.template file, and then you can test them all locally! :)

You can find more info in this discussion

Halliard answered 17/11, 2022 at 11:36 Comment(0)
L
0

Answering after a long time, but might help someone else. To deploy and test multiple lambdas from visual studio, you have to implement serverless.template. Check AWS SAM documentation.

You can start with this one - https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-build-test-severless-app.html

Luci answered 10/6, 2022 at 15:42 Comment(1)
that post is useful if you want to test your lambda functions calling AWS Gateway remotely but it doesn't provide the solution for this questionHalliard

© 2022 - 2024 — McMap. All rights reserved.