From 1f8c19e6bdacde5b4515cf36b9599a3e677cf13d Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 13 Jun 2022 23:10:52 -0400 Subject: [PATCH 1/2] Fix example in readme.md to new parameter type --- Libraries/src/Amazon.Lambda.Annotations/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/src/Amazon.Lambda.Annotations/README.md b/Libraries/src/Amazon.Lambda.Annotations/README.md index 2011394c2..12a857d55 100644 --- a/Libraries/src/Amazon.Lambda.Annotations/README.md +++ b/Libraries/src/Amazon.Lambda.Annotations/README.md @@ -104,7 +104,7 @@ public class Functions [LambdaFunction] - [HttpApi(HttpMethod.Put, HttpApiVersion.V2, "/process/{name}")] + [HttpApi(LambdaHttpMethod.Put, "/process/{name}", Version = HttpApiVersion.V2)] public async Task Process([FromServices] ITracker tracker, string name, [FromBody] string data) { tracker.Record(); From 1e138ab137dc4c06563cc8a94f836ffa95d08712 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 15 Jun 2022 20:44:52 -0400 Subject: [PATCH 2/2] The above two examples when used together will the use the value of LambdaRoleParameter as the role during deployment. Example shows using CloudFormation template Parameter named `LambdaRoleParameter` for the role of the Lambda function. ## Using References To Other Resources and Parameters in the template Document Undocmented Feature --- .../src/Amazon.Lambda.Annotations/README.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Libraries/src/Amazon.Lambda.Annotations/README.md b/Libraries/src/Amazon.Lambda.Annotations/README.md index 12a857d55..d007129fe 100644 --- a/Libraries/src/Amazon.Lambda.Annotations/README.md +++ b/Libraries/src/Amazon.Lambda.Annotations/README.md @@ -53,6 +53,35 @@ public class Functions } ``` +## Using References To Other Resources and Parameters in the template + +To use a reference to a Resource or Parameter in the template, prefix the value with `@`. Example shows using CloudFormation template Parameter named `LambdaRoleParameter` for the role of the Lambda function. +```csharp +public class Functions +{ + [LambdaFunction( Role="@LambdaRoleParameter")] + [RestApi("/plus/{x}/{y}")] + public int Plus(int x, int y) + { + return x + y; + } +} +``` + +and place in your template: + +``` + + "Parameters": { + "LambdaExecutionRole": { + "Type": "String" + } + }, + +``` + +The above two examples when used together will the use the value of LambdaRoleParameter as the role during deployment. + ## Source Generator To bridge the gap from Lambda Annotations programming model to the normal programming model a .NET source generator is included in this package.