aws / aws/serverless-application-model

Create apigateway permissions from openapi definitions

Open
#2,211 14 comments 6 reactions 0 assignees View on GitHub
area/api-gateway maintainer/need-followup stage/pm-review type/feature
Dominant language
Python
Stars
9.6k
Forks
2.5k
Avg merge
1d 11h
Merged PRs (30d)
7

Description

### Describe your idea/feature/enhancement

Hey team, recently tried building out a rest API using `AWS::Serverless::Api` and openapi via DefinitionBody. It's great having my OpenAPI schemas converted to API gateway models and validation 💯 .

The only thing that's missing would be to have **apigw permissions automatically created.**

For example, the `Events` property on `AWS::Serverless::Function` automatically creates permissions for apigw to invoke the lambda.

The OpenAPI schema already defines the lambda handler via `x-amazon-apigateway-integration`, so it should be possible to create this permission in the background.

```yml
x-amazon-apigateway-integration:
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations
```

### Proposal

Parse the DefinitionBody of `AWS::Serverless::Api` and create a `AWS::Lambda::Permission` resource for the attached lambda function.

Things to consider:
1. This requires no changes to the [SAM Spec](https://github.com/awslabs/serverless-application-model)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.