Skip to content

Commit 9518468

Browse files
authored
Merge pull request #1202 from hounddog22030/master
readme.md: Fix example and document highly useful, undocumented feature
2 parents 1fcca82 + ae3259b commit 9518468

File tree

1 file changed

+30
-1
lines changed
  • Libraries/src/Amazon.Lambda.Annotations

1 file changed

+30
-1
lines changed

Libraries/src/Amazon.Lambda.Annotations/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ public class Functions
5353
}
5454
```
5555

56+
## Using References To Other Resources and Parameters in the template
57+
58+
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.
59+
```csharp
60+
public class Functions
61+
{
62+
[LambdaFunction( Role="@LambdaRoleParameter")]
63+
[RestApi("/plus/{x}/{y}")]
64+
public int Plus(int x, int y)
65+
{
66+
return x + y;
67+
}
68+
}
69+
```
70+
71+
and place in your template:
72+
73+
```
74+
75+
"Parameters": {
76+
"LambdaExecutionRole": {
77+
"Type": "String"
78+
}
79+
},
80+
81+
```
82+
83+
The above two examples when used together will the use the value of LambdaRoleParameter as the role during deployment.
84+
5685
## Source Generator
5786

5887
To bridge the gap from Lambda Annotations programming model to the normal programming model a .NET source generator is included in this package.
@@ -104,7 +133,7 @@ public class Functions
104133

105134

106135
[LambdaFunction]
107-
[HttpApi(HttpMethod.Put, HttpApiVersion.V2, "/process/{name}")]
136+
[HttpApi(LambdaHttpMethod.Put, "/process/{name}", Version = HttpApiVersion.V2)]
108137
public async Task Process([FromServices] ITracker tracker, string name, [FromBody] string data)
109138
{
110139
tracker.Record();

0 commit comments

Comments
 (0)