You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tools/LambdaTestTool/README.md
+90-19Lines changed: 90 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -14,41 +14,113 @@ The AWS .NET Mock Lambda Test Tool is a tool that can be used to load a .NET Cor
14
14
-[Configure for Visual Studio for Mac](#configure-for-visual-studio-for-mac)
15
15
-[Known Limitations](#known-limitations)
16
16
17
-
## Getting Help
17
+
## Getting help
18
18
19
19
This tool is currently in preview and there are some known limitations. For questions and problems please open a GitHub issue in this repository.
20
20
21
+
## Versions of the tool
22
+
23
+
There are separate versions of this tool for each support .NET Core Lambda runtime. Currently there are too supported versions .NET Core 2.1
24
+
and .NET Core 3.1. When using the AWS [AWS Toolkit for Visual Studio](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017)
25
+
26
+
27
+
|.NET Core Version | Tool NuGet Package | Tool executable|
In the Lambda environment an IAM Role is assigned to the function that delivers AWS Credentials to the Lambda compute environment. When service clients from the AWS SDK for .NET are created without explicit credentials the SDK will search the running environment for credentials and find the credentials delivered by the IAM role.
34
+
In the Lambda environment an IAM Role is assigned to the function that delivers AWS Credentials to the Lambda compute environment. When
35
+
service clients from the AWS SDK for .NET are created without explicit credentials the SDK will search the running environment for
36
+
credentials and find the credentials delivered by the IAM role.
24
37
25
-
IAM Roles are **not** used with this tool. Instead a credential profile is selected from the host machine's credential before the code is run. The **AWS_PROFILE** environment variable is set to the selected profile. Just like in the Lambda environment when a service client is created without explicit credentials the SDK searches for credentials and will find the AWS_PROFILE environment variable and retrieve the credentials from the local credential file.
38
+
IAM Roles are **not** used with this tool. Instead a credential profile is selected from the host machine's credential before the code is
39
+
run. The **AWS_PROFILE** environment variable is set to the selected profile. Just like in the Lambda environment when a service client
40
+
is created without explicit credentials the SDK searches for credentials and will find the AWS_PROFILE environment variable and retrieve the
41
+
credentials from the local credential file.
26
42
27
-
## Installing and Running
43
+
## Installing and running
28
44
29
-
The tool is distributed as a .NET Global Tool via the NuGet package Amazon.Lambda.TestTool-2.1. To install the tool execute the following command:
45
+
The tool is distributed as .NET Global Tools via the NuGet packages. There is a package for each Lambda runtime supported which the table above describes.
46
+
The suffix of each package indicates the version of .NET Core the package is for. To install the tool execute the following command:
30
47
31
48
```
32
-
dotnet tool install -g Amazon.Lambda.TestTool-2.1
49
+
dotnet tool install -g Amazon.Lambda.TestTool-3.1
33
50
```
34
51
35
52
To update the tool run the following command:
36
53
37
54
```
38
-
dotnet tool update -g Amazon.Lambda.TestTool-2.1
55
+
dotnet tool update -g Amazon.Lambda.TestTool-3.1
39
56
```
40
57
41
58
The main intention for this tool is to make it easy to debug .NET Core Lambda code from an IDE. The tool can be run without an IDE by executing the following command from the project directory. The .NET Core Lambda project **must be built for debug** before running this tool. It doesn't do this automatically because it is assumed an IDE will have built the project before executing this program.
42
59
43
60
```
44
-
dotnet lambda-test-tool-2.1
61
+
dotnet lambda-test-tool-3.1
45
62
```
46
63
64
+
## Skip using the web interface
65
+
66
+
In the default mode this tool uses the web interface to select the .NET Lambda code to run. It is also possible to skip using the web interface and identify the .NET Lambda code to run
67
+
using command line arguments. The key command line argument to set is <b>--no-ui</b> which will turn off the web interface. Using the <b>--help</b> command line argument you can see the list of
68
+
arguments that can be used to identify the .NET Lambda code and set environment settings like aws profile and region as well as a payload JSON document to be used as the function input.
The .NET Lambda Test Tool can be launched in 2 modes. The default mode is to launch a web interface to select the Lambda code
75
+
to execute with in the Lambda test tool. The second mode skips using the web interface and the Lambda code is identified
76
+
using the commandline switches as described below. To switch to the no web interface mode use the --no-ui command line switch.
77
+
78
+
These options are valid for either mode the Lambda test tool is running in.
79
+
80
+
--path <directory> The path to the lambda project to execute. If not set then the current directory will be used.
81
+
82
+
These options are valid when using the web interface to select and execute the Lambda code.
47
83
48
-
### Why the 2.1 Suffix?
84
+
--port <port-number> The port number used for the test tool's web interface.
85
+
--no-launch-window Disable auto launching the test tool's web interface in a browser.
49
86
50
-
Since this tool loads .NET Core Lambda code within its process the version of .NET Core must match the target Lambda Runtime, which is .NET Core 2.1 in this case. When future .NET Core Lambda environments become available a new NuGet package will be released with the suffix updated to match the target framework.
87
+
These options are valid in the no web interface mode.
51
88
89
+
--no-ui Disable launching the web interface and immediately execute the Lambda code.
90
+
--profile <profile-name> Set the AWS credentials profile to provide credentials to the Lambda code.
91
+
If not set the profile from the config file will be used.
92
+
--region <region-name> Set the AWS region to as the default region for the Lambda code being executed.
93
+
If not set the region from the config file will be used.
94
+
--config-file <file-name> The config file to read for Lambda settings. If not set than aws-lambda-tools-defaults.json
95
+
will be used.
96
+
--function-handler <handler-string> The Lambda function handler to identify the code to run. If not set then the function handler
97
+
from the config file will be used. This is the format of <assembly::type-name::method-name>.
98
+
--payload <file-name> The JSON payload to send to the Lambda function. This can be either an inline string or a
99
+
file path to a JSON file.
100
+
--pause-exit <true or false> If set to true the test tool will pause waiting for a key input before exiting. The is useful
101
+
when executing from an IDE so you can avoid having the output window immediately disappear after
102
+
executing the Lambda code. The default value is true.
103
+
</pre>
104
+
105
+
For command line arguments not set the defaults and config file will be used to determine the .NET Lambda code to run. For example if you just use the <b>--no-ui</b> argument then the
106
+
<b>aws-lambda-tools-defaults.json</b> will be searched for and used if found. The tool when then use the function handler, profile and region specified in the configuration file to run
107
+
.NET Lambda code.
108
+
109
+
Here is an example of a <b>launchSettings.json</b> file configured to use this tool without the web interface. Only <b>--no-ui</b> and <b>--payload</b> are set turning off the web interface
110
+
and indicating the contents of the payload.json file should be used as the function input. The function handler is identified from the project's <b>aws-lambda-tools-defaults.json</b> file.
@@ -73,7 +145,7 @@ When a project is opened in Visual Studio the toolkit will detect the project is
73
145
74
146
Before using Visual Studio Code you must follow the instructions above on installing the .NET Mock Lambda Test Tool.
75
147
76
-
To debug with Visual Studio Code and the .NET Mock Lambda Test Tool edit the [launch.json](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) configuration file and have the `program` property point to `dotnet-lambda-test-tool-2.1.exe` and make sure `cwd` is pointing the .NET Core Lambda project. Note that on a non-windows environment the executable will be called `dotnet-lambda-test-tool-2.1` without the ".exe" at the end. The `dotnet-lambda-test-tool-2.1.exe` executable can be found in the `.dotnet/tools` directory under your home directory. Depending on your file system settings, the `.dotnet` directory can appear hidden.
148
+
To debug with Visual Studio Code and the .NET Mock Lambda Test Tool edit the [launch.json](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) configuration file and have the `program` property point to `dotnet-lambda-test-tool-.1.exe` and make sure `cwd` is pointing the .NET Core Lambda project. Note that on a non-windows environment the executable will be called `dotnet-lambda-test-tool-3.1` without the ".exe" at the end. The `dotnet-lambda-test-tool-3.1.exe` executable can be found in the `.dotnet/tools` directory under your home directory. Depending on your file system settings, the `.dotnet` directory can appear hidden.
77
149
78
150
```json
79
151
{
@@ -84,7 +156,7 @@ To debug with Visual Studio Code and the .NET Mock Lambda Test Tool edit the [la
@@ -105,10 +177,10 @@ To customize the launch behavior for the debugger, you can pass additional argum
105
177
106
178
Before using JetBrains Rider you must follow the instructions above on installing the .NET Mock Lambda Test Tool.
107
179
108
-
Configuring Rider to use the .NET Mock Lambda Test Tool is a little different compared to Visual Studio. For Rider the executable target needs to be the main assembly `Amazon.Lambda.TestTool.dll` for the Test Tool and **not** the Global Tool executable `dotnet-lambda-test-tool-2.1`. The path to `Amazon.Lambda.TestTool.dll` is:
180
+
Configuring Rider to use the .NET Mock Lambda Test Tool is a little different compared to Visual Studio. For Rider the executable target needs to be the main assembly `Amazon.Lambda.TestTool.dll` for the Test Tool and **not** the Global Tool executable `dotnet-lambda-test-tool-3.1`. The path to `Amazon.Lambda.TestTool.dll` is:
Remember when you update your version of the .NET Mock Lambda Test Tool to update the nuget versions numbers in this path string for your IDE's configuration.
@@ -128,10 +200,10 @@ After following these steps, any time you start the debugger in Rider, it will s
128
200
129
201
Before using Visual Studio for Mac you must follow the instructions above on installing the .NET Mock Lambda Test Tool.
130
202
131
-
Configuring Visual Studio for Mac to use the .NET Mock Lambda Test Tool is a little different compared to Visual Studio. For Visual Studio for Mac the executable target needs to be the main assembly `Amazon.Lambda.TestTool.dll` for the Test Tool and **not** the Global Tool executable `dotnet-lambda-test-tool-2.1`. The path to `Amazon.Lambda.TestTool.dll` is:
203
+
Configuring Visual Studio for Mac to use the .NET Mock Lambda Test Tool is a little different compared to Visual Studio. For Visual Studio for Mac the executable target needs to be the main assembly `Amazon.Lambda.TestTool.dll` for the Test Tool and **not** the Global Tool executable `dotnet-lambda-test-tool-3.1`. The path to `Amazon.Lambda.TestTool.dll` is:
Remember when you update your version of the .NET Mock Lambda Test Tool to update the nuget versions numbers in this path string for your IDE's configuration.
137
209
@@ -148,6 +220,5 @@ Once this is done when you start the debugger in Visual Studio for Mac it will l
148
220
149
221
## Known Limitations
150
222
151
-
* YAML based CloudFormation templates are not yet supported.
152
223
* No mechanism for setting custom Environment variables.
153
224
* NuGet packages that use native dependencies are not supported.
0 commit comments