Description
Describe the feature
Add possibility to reference existing APIs on functions through annotations rather than today where manual template changes are needed.
Use Case
When using lambda annotations with multiple functions under the same gateway (for auth purposes, certificates, domains etc) it's tiresome and possibly error-prone to manually handle template changes.
Proposed Solution
On the lambda functions, add functionality to reference an existing API. An example usage could look like this:
[LambdaFunction(Name = "UpdateStatus")]
[RestApi(LambdaHttpMethod.Post, "/{x}/{y}/endpoint-path", "OrdersApiGateway")]
public APIGatewayProxyResponse Execute() {
}
where the new addition is to the "RestApi" path, where a new parameter (RestApiId) is configurable. In the example the value "OrdersApiGateway" is used.
This will then in the template.json|yaml add
{
"....": "....",
"RestApiId": {
"Ref": "OrdersApiGateway"
}
}
to the events part of the template which should be a reference to a resource in the template which has the API Gateway configured.
If the usage looks OK it will be added to REST API attribute here
https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.Annotations/APIGateway/RestApiAttribute.cs
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
AWS .NET SDK and/or Package version used
Amazon.Lambda.Annotations
Targeted .NET Platform
.NET 6
Operating System and version
MacOS Ventura