aws / aws/serverless-application-model
Feature request: configure API gateway extensions in SAM template
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Description
## Description:
When using Swagger/Open API specifications to configure an API Gateway, you have to add your own [API Gateway Swagger Extensions](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html). This means your API specification is tainted with AWS-specific data. This is a feature request for some way of configuring functions and APIs from the SAM template and have it implicitly annotate the Open API specification.
### Example
Extend the [`Api` event source type ](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api) so that you can map the request path and method to a particular Lambda invocation. This would generate the `x-amazon-apigateway-integration` field in the Open API specification implicitly when deploying. Example configuration (the `Extensions` field onwards):
```yaml
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs8.10
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
Extensions:
IntegrationResponse:
uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloWorldFunction.Arn}/invocations # This may also be implicit?
contentHandling: "CONVERT_TO_TEXT"
```
### Rationale
The idea here is to keep your Open API specification pure and free from AWS-specific data. This should make it much easier to configure the relationship between your Lambdas and API Gateway, because you only have to add configuration in the SAM template.
Contributor guide
Assessment
This issue has not been assessed yet.