-
Notifications
You must be signed in to change notification settings - Fork 504
Improve Lambda Test Tool v2 getting-started docs and add samples #2494
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
Open
GarrettBeatty
wants to merge
3
commits into
dev
Choose a base branch
from
docs/testtool-v2-getting-started
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
Tools/LambdaTestTool-v2/samples/AddFunctionClassLibrary/AddFunctionClassLibrary.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <AWSProjectType>Lambda</AWSProjectType> | ||
| <AssemblyName>AddFunctionClassLibrary</AssemblyName> | ||
| <!-- Produces the .deps.json / .runtimeconfig.json the launch profile references. --> | ||
| <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | ||
| <!-- Copy NuGet dependencies (Amazon.Lambda.Core, etc.) next to the output DLL so the | ||
| function can be launched from the command line without extra probing paths. --> | ||
| <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Amazon.Lambda.Core" Version="2.5.1" /> | ||
| <PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="3.0.0" /> | ||
| <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
20 changes: 20 additions & 0 deletions
20
Tools/LambdaTestTool-v2/samples/AddFunctionClassLibrary/Function.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using Amazon.Lambda.APIGatewayEvents; | ||
| using Amazon.Lambda.Core; | ||
|
|
||
| [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.CamelCaseLambdaJsonSerializer))] | ||
|
|
||
| namespace AddFunctionClassLibrary; | ||
|
|
||
| public class Function | ||
| { | ||
| /// <summary> | ||
| /// Adds the two path parameters {x} and {y} and returns the sum. | ||
| /// Handler string: AddFunctionClassLibrary::AddFunctionClassLibrary.Function::Add | ||
| /// </summary> | ||
| public int Add(APIGatewayHttpApiV2ProxyRequest request, ILambdaContext context) | ||
| { | ||
| var x = int.Parse(request.PathParameters["x"]); | ||
| var y = int.Parse(request.PathParameters["y"]); | ||
| return x + y; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
Tools/LambdaTestTool-v2/samples/AddFunctionClassLibrary/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "profiles": { | ||
| "LambdaTestTool": { | ||
| "commandName": "Executable", | ||
| "executablePath": "dotnet", | ||
| "workingDirectory": ".\\bin\\$(Configuration)\\net10.0", | ||
| "commandLineArgs": "exec --depsfile ./AddFunctionClassLibrary.deps.json --runtimeconfig ./AddFunctionClassLibrary.runtimeconfig.json %USERPROFILE%/.dotnet/tools/.store/amazon.lambda.testtool/{TEST_TOOL_VERSION}/amazon.lambda.testtool/{TEST_TOOL_VERSION}/content/Amazon.Lambda.RuntimeSupport/net10.0/Amazon.Lambda.RuntimeSupport.TestTool.dll AddFunctionClassLibrary::AddFunctionClassLibrary.Function::Add", | ||
| "environmentVariables": { | ||
| "AWS_LAMBDA_RUNTIME_API": "localhost:5050/AddLambdaFunction" | ||
| } | ||
| } | ||
| } | ||
| } |
78 changes: 78 additions & 0 deletions
78
Tools/LambdaTestTool-v2/samples/AddFunctionClassLibrary/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # AddFunctionClassLibrary | ||
|
|
||
| The same "add two numbers" function as [`AddFunctionTopLevel`](../AddFunctionTopLevel), but as a **class library** (a handler method rather than top-level statements). A class-library function is launched by running its assembly under the test tool's copy of the Lambda runtime support library. You can do this from the command line or from an IDE. | ||
|
|
||
| Handler: `AddFunctionClassLibrary::AddFunctionClassLibrary.Function::Add` | ||
|
|
||
| ## Setup (once) | ||
|
|
||
| The `.csproj` sets `<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>` so the function's NuGet dependencies (e.g. `Amazon.Lambda.Core.dll`) are copied next to the output DLL — required for the command-line launch below. | ||
|
|
||
| Find your installed test tool version, which you'll substitute for `{TEST_TOOL_VERSION}`: | ||
|
|
||
| ``` | ||
| dotnet lambda-test-tool info | ||
| ``` | ||
|
|
||
| (or `dotnet tool list -g`). For example, `0.15.0`. | ||
|
|
||
| > The runtime support assembly is `Amazon.Lambda.RuntimeSupport.TestTool.dll` — renamed from `Amazon.Lambda.RuntimeSupport.dll` to avoid conflicting with the version your function references. | ||
|
|
||
| ## Run it (command line) | ||
|
|
||
| **1. Build the function:** | ||
|
|
||
| ``` | ||
| dotnet build | ||
| ``` | ||
|
|
||
| **2. Set the API Gateway route** (this directory): | ||
|
|
||
| ```bash | ||
| # Linux/macOS | ||
| export APIGATEWAY_EMULATOR_ROUTE_CONFIG='{"LambdaResourceName":"AddLambdaFunction","HttpMethod":"Get","Path":"/add/{x}/{y}","Endpoint":"http://localhost:5050"}' | ||
| ``` | ||
|
|
||
| ```powershell | ||
| # Windows (PowerShell) | ||
| $env:APIGATEWAY_EMULATOR_ROUTE_CONFIG='{"LambdaResourceName":"AddLambdaFunction","HttpMethod":"Get","Path":"/add/{x}/{y}","Endpoint":"http://localhost:5050"}' | ||
| ``` | ||
|
|
||
| **3. Start the test tool** (same terminal): | ||
|
|
||
| ``` | ||
| dotnet lambda-test-tool start --lambda-emulator-port 5050 --api-gateway-emulator-port 5051 --api-gateway-emulator-mode HttpV2 | ||
| ``` | ||
|
|
||
| **4. Start the function** from its build output directory (separate terminal), replacing `{TEST_TOOL_VERSION}` with your installed version: | ||
|
|
||
| ```bash | ||
| # Linux/macOS | ||
| cd bin/Debug/net10.0 | ||
| export AWS_LAMBDA_RUNTIME_API="localhost:5050/AddLambdaFunction" | ||
|
|
||
| dotnet exec \ | ||
| --depsfile ./AddFunctionClassLibrary.deps.json \ | ||
| --runtimeconfig ./AddFunctionClassLibrary.runtimeconfig.json \ | ||
| "$HOME/.dotnet/tools/.store/amazon.lambda.testtool/{TEST_TOOL_VERSION}/amazon.lambda.testtool/{TEST_TOOL_VERSION}/content/Amazon.Lambda.RuntimeSupport/net10.0/Amazon.Lambda.RuntimeSupport.TestTool.dll" \ | ||
| "AddFunctionClassLibrary::AddFunctionClassLibrary.Function::Add" | ||
| ``` | ||
|
|
||
| **5. Invoke it:** | ||
|
|
||
| ``` | ||
| curl "http://localhost:5051/add/5/3" | ||
| # => 8 | ||
| ``` | ||
|
|
||
| ## Run it (IDE: Visual Studio / Rider) | ||
|
|
||
| The committed [`launchSettings.json`](Properties/launchSettings.json) wraps the same command as an `Executable` profile you can launch with F5. Before using it, replace `{TEST_TOOL_VERSION}` (it appears **twice** in the `commandLineArgs` `.store` path) with your installed version. | ||
|
|
||
| The other values are already set for this project: target framework `net10.0`, deps/runtimeconfig file names, and the handler string. | ||
|
|
||
| > This profile relies on the IDE expanding `$(Configuration)` and resolving `workingDirectory`. Plain `dotnet run --launch-profile` does **not** do this — use the command-line steps above outside an IDE. | ||
|
|
||
| > The profile is written for **Windows** (`%USERPROFILE%`, backslashes). On **Linux/macOS**, replace `%USERPROFILE%` with `$HOME` and use forward slashes in `workingDirectory` (`./bin/$(Configuration)/net10.0`). | ||
|
|
||
| Then set `APIGATEWAY_EMULATOR_ROUTE_CONFIG`, start the test tool (steps 2–3 above), press F5 on the `LambdaTestTool` profile, and invoke with the step 5 curl. |
19 changes: 19 additions & 0 deletions
19
Tools/LambdaTestTool-v2/samples/AddFunctionTopLevel/AddFunctionTopLevel.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <AWSProjectType>Lambda</AWSProjectType> | ||
| <AssemblyName>AddFunctionTopLevel</AssemblyName> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Amazon.Lambda.Core" Version="2.5.1" /> | ||
| <PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="3.0.0" /> | ||
| <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.13.0" /> | ||
| <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
17 changes: 17 additions & 0 deletions
17
Tools/LambdaTestTool-v2/samples/AddFunctionTopLevel/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| using Amazon.Lambda.APIGatewayEvents; | ||
| using Amazon.Lambda.Core; | ||
| using Amazon.Lambda.RuntimeSupport; | ||
| using Amazon.Lambda.Serialization.SystemTextJson; | ||
|
|
||
| // Adds the two path parameters {x} and {y} and returns the sum. | ||
| // Uses the HTTP API v2 request shape, so run the API Gateway emulator in HttpV2 mode. | ||
| var handler = (APIGatewayHttpApiV2ProxyRequest request, ILambdaContext context) => | ||
| { | ||
| var x = int.Parse(request.PathParameters["x"]); | ||
| var y = int.Parse(request.PathParameters["y"]); | ||
| return (x + y).ToString(); | ||
| }; | ||
|
|
||
| await LambdaBootstrapBuilder.Create(handler, new CamelCaseLambdaJsonSerializer()) | ||
| .Build() | ||
| .RunAsync(); |
10 changes: 10 additions & 0 deletions
10
Tools/LambdaTestTool-v2/samples/AddFunctionTopLevel/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "profiles": { | ||
| "AddLambdaFunction": { | ||
| "commandName": "Project", | ||
| "environmentVariables": { | ||
| "AWS_LAMBDA_RUNTIME_API": "localhost:5050/AddLambdaFunction" | ||
| } | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
Tools/LambdaTestTool-v2/samples/AddFunctionTopLevel/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # AddFunctionTopLevel | ||
|
|
||
| The [Quick Start](../../README.md#quick-start) function: a top-level-statements Lambda that adds two numbers, invoked through the API Gateway emulator. Uses the HTTP API v2 request shape, so the API Gateway emulator runs in `HttpV2` mode. | ||
|
|
||
| ## Run it | ||
|
|
||
| **1. In this directory, set the API Gateway route** the emulator should expose: | ||
|
|
||
| ```bash | ||
| # Linux/macOS | ||
| export APIGATEWAY_EMULATOR_ROUTE_CONFIG='{"LambdaResourceName":"AddLambdaFunction","HttpMethod":"Get","Path":"/add/{x}/{y}","Endpoint":"http://localhost:5050"}' | ||
| ``` | ||
|
|
||
| ```powershell | ||
| # Windows (PowerShell) | ||
| $env:APIGATEWAY_EMULATOR_ROUTE_CONFIG='{"LambdaResourceName":"AddLambdaFunction","HttpMethod":"Get","Path":"/add/{x}/{y}","Endpoint":"http://localhost:5050"}' | ||
| ``` | ||
|
|
||
| **2. Start the test tool** (same terminal): | ||
|
|
||
| ``` | ||
| dotnet lambda-test-tool start --lambda-emulator-port 5050 --api-gateway-emulator-port 5051 --api-gateway-emulator-mode HttpV2 | ||
| ``` | ||
|
|
||
| **3. Start the function** (separate terminal, this directory): | ||
|
|
||
| ``` | ||
| dotnet run --launch-profile AddLambdaFunction | ||
| ``` | ||
|
|
||
| **4. Invoke it:** | ||
|
|
||
| ``` | ||
| curl "http://localhost:5051/add/5/3" | ||
| # => 8 | ||
| ``` | ||
|
|
||
| You can also invoke the function directly (without API Gateway) from the web UI that opens at `http://localhost:5050`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Lambda Test Tool v2 — Sample Projects | ||
|
|
||
| Runnable starter functions for the [AWS Lambda Test Tool](../README.md). Each is a minimal, self-contained project with its own README and a ready-to-use launch profile. | ||
|
|
||
| | Sample | What it shows | Emulator setup | | ||
| |--------|---------------|----------------| | ||
| | [`AddFunctionTopLevel`](AddFunctionTopLevel) | Top-level-statements function behind the API Gateway emulator (the [Quick Start](../README.md#quick-start)). | Lambda + API Gateway (`HttpV2`) | | ||
| | [`AddFunctionClassLibrary`](AddFunctionClassLibrary) | A class-library function with a pre-filled `Executable` launch profile. | Lambda + API Gateway (`HttpV2`) | | ||
| | [`SQSProcessor`](SQSProcessor) | An `SQSEvent` handler, testable via the SQS event source or the built-in `sqs.json` sample event. | Lambda (+ optional SQS event source) | | ||
| | [`ToUpperFunction`](ToUpperFunction) | A minimal, zero-dependency function for exploring the web UI and sample events. | Lambda only | | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - .NET 10 SDK (the samples target `net10.0`). To build them with an older SDK, change `<TargetFramework>` to `net8.0` or `net9.0`. | ||
| - The test tool installed: `dotnet tool install -g amazon.lambda.testtool` (see the [main README](../README.md#prerequisites)). | ||
|
|
||
| Start with [`AddFunctionTopLevel`](AddFunctionTopLevel) if you're new — it's the lowest-friction path from install to a working invocation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using Amazon.Lambda.Core; | ||
| using Amazon.Lambda.RuntimeSupport; | ||
| using Amazon.Lambda.Serialization.SystemTextJson; | ||
| using Amazon.Lambda.SQSEvents; | ||
|
|
||
| // Processes a batch of SQS messages, logging each message body. | ||
| // Test it either with the built-in "sqs.json" sample event from the web UI, | ||
| // or by wiring a real queue with --sqs-eventsource-config (see this sample's README). | ||
| var handler = (SQSEvent evnt, ILambdaContext context) => | ||
| { | ||
| foreach (var message in evnt.Records) | ||
| { | ||
| context.Logger.LogLine($"Processing message {message.MessageId}: {message.Body}"); | ||
| } | ||
|
|
||
| context.Logger.LogLine($"Processed {evnt.Records.Count} message(s)."); | ||
| }; | ||
|
|
||
| await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer()) | ||
| .Build() | ||
| .RunAsync(); |
10 changes: 10 additions & 0 deletions
10
Tools/LambdaTestTool-v2/samples/SQSProcessor/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "profiles": { | ||
| "SQSProcessor": { | ||
| "commandName": "Project", | ||
| "environmentVariables": { | ||
| "AWS_LAMBDA_RUNTIME_API": "localhost:5050/SQSProcessor" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # SQSProcessor | ||
|
|
||
| An `SQSEvent` handler that logs each message body. Demonstrates the shape of an SQS-triggered Lambda and the [SQS event source](../../README.md#sqs-event-source). You can test it two ways. | ||
|
|
||
| ## Option A: With the built-in sample event (no AWS needed) | ||
|
|
||
| **1. Start the Lambda emulator:** | ||
|
|
||
| ``` | ||
| dotnet lambda-test-tool start --lambda-emulator-port 5050 | ||
| ``` | ||
|
|
||
| **2. Start the function** (separate terminal, this directory): | ||
|
|
||
| ``` | ||
| dotnet run --launch-profile SQSProcessor | ||
| ``` | ||
|
|
||
| **3. In the web UI** (`http://localhost:5050`), select `SQSProcessor`, choose the built-in **`sqs.json`** sample from the Example Requests dropdown, and click **Invoke**. The message body is logged in the function's console. | ||
|
|
||
| ## Option B: With a real SQS queue (event source polling) | ||
|
|
||
| This polls an actual queue using your AWS credentials. | ||
|
|
||
| **1. Start the function** (separate terminal, this directory): | ||
|
|
||
| ``` | ||
| dotnet run --launch-profile SQSProcessor | ||
| ``` | ||
|
|
||
| **2. Start the test tool with the SQS event source** pointed at your queue: | ||
|
|
||
| ``` | ||
| dotnet lambda-test-tool start \ | ||
| --lambda-emulator-port 5050 \ | ||
| --sqs-eventsource-config "QueueUrl=https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>,FunctionName=SQSProcessor,Region=<region>" | ||
| ``` | ||
|
|
||
| Send a message to the queue; the tool batches it into an `SQSEvent`, invokes `SQSProcessor`, and (on success) deletes the message. See the [main README](../../README.md#sqs-event-source) for all supported config keys. |
19 changes: 19 additions & 0 deletions
19
Tools/LambdaTestTool-v2/samples/SQSProcessor/SQSProcessor.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <AWSProjectType>Lambda</AWSProjectType> | ||
| <AssemblyName>SQSProcessor</AssemblyName> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Amazon.Lambda.Core" Version="2.5.1" /> | ||
| <PackageReference Include="Amazon.Lambda.SQSEvents" Version="3.0.0" /> | ||
| <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.13.0" /> | ||
| <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
21 changes: 21 additions & 0 deletions
21
Tools/LambdaTestTool-v2/samples/ToUpperFunction/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using Amazon.Lambda.Core; | ||
| using Amazon.Lambda.RuntimeSupport; | ||
| using Amazon.Lambda.Serialization.SystemTextJson; | ||
|
|
||
| // A minimal function: uppercases the input string. | ||
| // Send the string "error" to see how the tool renders a thrown exception. | ||
| var handler = (string input, ILambdaContext context) => | ||
| { | ||
| context.Logger.LogLine($"Executing function with input: {input}"); | ||
|
|
||
| if (string.Equals("error", input, StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| throw new Exception("Forced error to demonstrate error rendering."); | ||
| } | ||
|
|
||
| return input?.ToUpper(); | ||
| }; | ||
|
|
||
| await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer()) | ||
| .Build() | ||
| .RunAsync(); |
10 changes: 10 additions & 0 deletions
10
Tools/LambdaTestTool-v2/samples/ToUpperFunction/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "profiles": { | ||
| "ToUpperFunction": { | ||
| "commandName": "Project", | ||
| "environmentVariables": { | ||
| "AWS_LAMBDA_RUNTIME_API": "localhost:5050/ToUpperFunction" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.