aws / aws/chalice

Add api config to customize API Gateway Responses

Open
#1,282 6 comments 7 reactions 0 assignees View on GitHub
proposals
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

There is a need and use for customizing API Gateway Responses in Chalice. Specifically, I mean the ones you can currently edit in the console on this page:

![image](https://user-images.githubusercontent.com/35938642/67136250-5a874800-f1e9-11e9-8835-804d328bdae3.png)

So you can set custom status response codes, headers, and possibly templates.

I'd started #1270 to try implementing it, but @stealthycoin it would be good to discuss the implementation in an issue. In the pr I tried implementing it in the chalice config, but as was pointed out, it would be more appropriate for this to be managed on the app itself, e.g.
```python
app = Chalice(app_name="helloworld")
app.api. =
```

So some things we need to address in this issue are:
1. What should the name of the property on `app.api` be?
- I personally like something like `gateway_responses`, but am open to other people's input.
2. How should this configuration be defined? There is the option of JSON, which as pointed out in the pr, is not as friendly. @stealthycoin suggested using a dict to define it. Here is a link to the possible values that we could define: https://docs.aws.amazon.com/apigateway/api-reference/resource/gateway-response/#properties
- I agree that this should be a dict, and we could make it a mapping of response types to config options. E.g.
```python
app.api.gateway_responses = {
'default_4xx': {
'response_parameters': {
'access-control-allow-origin': "'*'"
}
}
}
```
Maybe this is too verbose? I'd be happy to get some feedback or alternative options.

Contributor guide

Open the contributing guide

Research direction

Review the attempted implementation in #1270 and the AWS API Gateway gateway-response properties linked in the issue. Resolve the app.api property name and configuration shape before implementing support; done means the API Gateway responses can be configured for status codes, headers, and any supported templates.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
api, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.