Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Gateway: improve API for request parameters and responses #727

Closed
eladb opened this issue Sep 17, 2018 · 0 comments · Fixed by #2960
Closed

API Gateway: improve API for request parameters and responses #727

eladb opened this issue Sep 17, 2018 · 0 comments · Fixed by #2960
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway feature-request A feature should be added or improved.

Comments

@eladb
Copy link
Contributor

eladb commented Sep 17, 2018

The current API could probably be improved to remove some of cognitive load from users:

  • requestParameters
  • requestTemplates
  • integrationResponses
eladb pushed a commit that referenced this issue Sep 17, 2018
Introduce an initial construct library for API Gateway. By all means it does not cover 
the entire surface area of API Gateway, but provides basic support for defining 
API gateway configurations (resources/methods hierarchy).

Integration support includes `LambdaIntegration` which accepts a `lambda.Function`, 
sets up the appropriate permissions and binds it to an API method.

Includes many "smart defaults" at every level such as:

- Automatically define a `Deployment` and a `Stage` for the API, which will be recreated every time the API configuration changes (by generating the logical ID of the AWS::ApiGateway::Deployment resource from a hash of the API configuration, similarly to SAM).
- Automatically configure a role for API Gateway to allow writing CloudWatch logs and alarms.
- Specify `defaultIntegration` at the API level which will apply to all methods without integration.

Supports defining APIs like this:

```ts
const integ = new apigw.LambdaIntegration(toysLambdaHandler);
const api = new apigw.RestApi(this, 'my-awesome-api');

api.root.onMethod('GET', new apigw.HttpIntegration('https://amazon.com/toys'));

const toys = api.root.addResource('toys', { defaultIntegration: integ });
toys.addMethod('ANY');

const toy = toys.addResource('{toy}');
toy.addMethod('GET'); // get a toy
toy.addMethod('DELETE'); // remove a toy
```

See [README] for more details.

[README]: https://github.com/awslabs/aws-cdk/blob/c99e7285e7b24700cfd4d52f6da32cffe12c511c/packages/%40aws-cdk/aws-apigateway/README.md

### Framework Changes

 * __resolve__: allow object keys to include tokens, as long as they resolvable to strings.
 * __assert__: invoke `stack.validateTree()` by default for `expect(stack)` to simulate synthesis.

----

* Features not supported yet are listed here: #727, #723
* Fixes #602, copy: @hassankhan
@debora-ito debora-ito added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Nov 7, 2018
@srchase srchase added feature-request A feature should be added or improved. and removed enhancement labels Jan 3, 2019
eladb pushed a commit that referenced this issue Jun 27, 2019
…d validators (#2960)

Fixes #905: "apigateway: "methodResponses" is missing from MethodOptions"
Fixes #1695: apigateway: missing support for models
Fixes #727: API Gateway: improve API for request parameters and responses
Fixes #723: API Gateway: missing features
Fixes #2957: RestApi to use logical id as a name for APIs instead of name of current construct
Adds support for JsonSchema in Model
Aligns Model to the PhysicalName convention.
No breaking change, documentation updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants