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

Add README #1971

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

Add README #1971

wants to merge 10 commits into from

Conversation

GarrettBeatty
Copy link
Contributor

Issue #, if available: DOTNET-7956

Description of changes: Add README

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


The AWS Lambda Test Tool is an evolution of the previous AWS .NET Mock Lambda Test Tool, with several key improvements:

### New Features
Copy link
Contributor Author

Choose a reason for hiding this comment

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

anything else worth mentioning here?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@GarrettBeatty GarrettBeatty marked this pull request as ready for review February 7, 2025 18:46

The AWS Lambda Test Tool is an evolution of the previous AWS .NET Mock Lambda Test Tool, with several key improvements:

### New Features
Copy link
Member

Choose a reason for hiding this comment

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


This tool is currently in preview and there are some known limitations. For questions and problems please open a GitHub issue in this repository.

## Installing
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a section before here that directs users to the Aspire experience something like

## .NET Aspire integration
The easiest way to get started using the features of the new test tool is with .NET Aspire. The integration takes care of installing the tool and provides .NET Aspire extension methods for configuring your Lambda functions and API Gateway emulator in the .NET Aspire AppHost. It avoids all steps list below for installing the tooling and setting up environment variables.

Check out the following tracker issue for information on the .NET Aspire integration and steps for getting started. https://github.com/aws/integrations-on-dotnet-aspire-for-aws/issues/17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated


```

## Running the Test Tool Project via an IDE
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand the point of this section. We don't expect users to download our repository and run it unless they want to contribute to the repo. In that case this would be information to provide in our contributing guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will move this to the contribution guide

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i moved this to a separate contribution guide

}
```

### 2. Configuration Files
Copy link
Member

Choose a reason for hiding this comment

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

I would organize this different and out the information about editing the launchsettings.json file under each of the options above. That way you can say for executable set the launchsetting to this. For class library set the launchsettings to this version. And be sure to explain the AWS_LAMBDA_RUNTIME_API environment variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have updated this section and also fixed the launchSettings for the classlibrary and have also added a snippet explaining the AWS_LAMBDA_RUNTIME_API variable


**aws-lambda-tools-defaults.json**

For top-level statements, your `aws-lambda-tools-defaults.json` should be:
Copy link
Member

Choose a reason for hiding this comment

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

As of right now our test tool or aspire integration don't do anything with aws-lambda-tools-defaults.json so I wouldn't talk about here.

Copy link
Contributor Author

@GarrettBeatty GarrettBeatty Feb 7, 2025

Choose a reason for hiding this comment

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

Doesnt the function handler name need to match in order for api gateway to work with it? Let me double check this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe it was just the AWS_LAMBDA_RUNTIME_API function name that needs to match. ill retest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i removed this part

"LambdaRuntimeClient_FunctionHandler": {
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
"commandName": "Executable",
"commandLineArgs": "exec --depsfile ./MyLambdaFunction.deps.json --runtimeconfig ./MyLambdaFunction.runtimeconfig.json %USERPROFILE%/.dotnet/tools/.store/amazon.lambda.testtool/0.0.2-preview/amazon.lambda.testtool/0.0.2-preview/content/Amazon.Lambda.RuntimeSupport/net8.0/Amazon.Lambda.RuntimeSupport.dll MyLambdaFunction::MyLambdaFunction.Function::Add",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

%USERPROFILE%/.dotnet/tools/.store/amazon.lambda.testtool/0.0.2-preview/amazon.lambda.testtool/0.0.2-preview/content/Amazon.Lambda.RuntimeSupport/net8.0/Amazon.Lambda.RuntimeSupport.dll MyLambdaFunction::MyLambdaFunction.Function::Add"

wasnt sure if there was an easy way to dynamically set the test tool version based on the current release number? or if there was a more simpler way to write this

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's the issue that norm was referring to the other day.

@GarrettBeatty GarrettBeatty requested a review from normj February 10, 2025 15:43

## Comparison with Previous Test Tool

The AWS Lambda Test Tool is an evolution of the previous AWS .NET Mock Lambda Test Tool, with several key improvements:
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a link to the old version to provide better context.


### New Features
- **API Gateway Emulation**: Direct support for testing API Gateway integrations locally
- New flow for loading Lambda functions that mimic's closer to the Lambda service. This solves many of the issues with the older tool when it came to loading dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

The sentence reads a bit weird to me. Also there shouldn't be an "'s" in "mimics"

This tool is currently in preview and there are some known limitations. For questions and problems please open a GitHub issue in this repository.

## .NET Aspire integration
The easiest way to get started using the features of the new test tool is with .NET Aspire. The integration takes care of installing the tool and provides .NET Aspire extension methods for configuring your Lambda functions and API Gateway emulator in the .NET Aspire AppHost. It avoids all steps list below for installing the tooling and setting up environment variables.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "all steps listed below"


## Installing

The tool is distributed as .NET Global Tools via the NuGet packages. To install the tool execute the following command:
Copy link
Contributor

Choose a reason for hiding this comment

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

"as a .NET global tool". I don't see the need to say "via the NuGet packages"

```

### API Gateway Emulator Mode
Use this mode when you want to test Lambda functions through API Gateway endpoints. This mode requires additional configuration through environment variables.
Copy link
Contributor

Choose a reason for hiding this comment

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

You should mention that this alone wouldn't work because the Lambda Runtime API is not running


Linux/macOS:
```bash
export APIGATEWAY_EMULATOR_ROUTE_CONFIG='{"LambdaResourceName":"AddLambdaFunction","HttpMethod":"Get","Path":"/add/{x}/{y}"}'
Copy link
Contributor

Choose a reason for hiding this comment

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

The command you gave above does not run the Lambda client so you need to add the endpoint to the env vars where the client is running.

"LambdaRuntimeClient_FunctionHandler": {
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
"commandName": "Executable",
"commandLineArgs": "exec --depsfile ./MyLambdaFunction.deps.json --runtimeconfig ./MyLambdaFunction.runtimeconfig.json %USERPROFILE%/.dotnet/tools/.store/amazon.lambda.testtool/0.0.2-preview/amazon.lambda.testtool/0.0.2-preview/content/Amazon.Lambda.RuntimeSupport/net8.0/Amazon.Lambda.RuntimeSupport.dll MyLambdaFunction::MyLambdaFunction.Function::Add",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's the issue that norm was referring to the other day.

There are three variables you may need to replace:

1. The test tool version `0.0.2-preview` in the above path to the `Amazon.Lambda.RuntimeSupport.dll` should be updated to the current test tool version.
2. The .net version `net8.0` should be the same version that your lambda project is using.
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention that we are distributing multiple target frameworks so users arent tied to net8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this and the other issues in latest commit

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.

3 participants