-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Examples with API Gateway #602
Comments
On a related note, I've written up an What I've got currently allows setting up the following API Gateway resources:
export type MethodType = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
export interface HttpConfig {
path: string;
method: MethodType;
cors?: boolean;
}
export interface LambdaConfig {
lambdaFn: Lambda.Function
http: HttpConfig
}
export type EndpointType = 'EDGE' | 'REGIONAL' | 'PRIVATE';
export interface ApiGatewayProps {
name: string;
endpoints: LambdaConfig[];
endpointTypes: EndpointType[];
cacheEncrypted?: boolean;
cacheSize?: '0.5' | '1.6' | '6.1' | '13.5' | '28.4' | '58.2' | '118' | '237';
cacheTtl?: number;
caching?: boolean;
logging?: boolean;
logLevel?: 'OFF' | 'ERROR' | 'INFO';
metrics?: boolean;
stageName: string;
}
new ApiGateway(this, 'MyAPI', {
name: 'MyAPI',
stageName: 'dev',
endpointTypes: [ 'EDGE' ],
logging: true,
endpoints: [
{
lambdaFn: lambdaFn,
http: {
path: '/',
method: 'GET'
}
}
],
}); |
@hassankhan, that is amazing! If you really want to contribute this to the CDK standard library, we would gladly accept it! In that case, I would have some style pointers on your code to bring it in line with the rest of our library, and I can tell you about what we expect from testing. However, before you put in all the effort I believe that @mindstorms6 also had some API-gateway related code lying around, and it would be a waste if you both spent effort on it. So I'll let him chime in first to see where his code is at, and then we can discuss specifics further. |
I'm all for this - my efforts have been focused on using the Also, looping in @RomainMuller |
Awesome, I'll try and get a PR once #474 is resolved 👍 |
Okay, some comments then:
|
Is the aws-apigateway usable in production? It is really hard to understand how to create a stack that includes a apigateway. A small example would be nice as starting point. |
@hpfs74 I'm sure the |
That would be awesome @hassankhan |
@mindstorms6 your work has been creating the cfn template with the serverless:transform, and then you let cfn do the actual transform to create the template? |
I am working on an API gateway construct library. Stay tuned! |
Really sorry @eladb, couldn't find the time to make the PR. Is it still worth making one or is it better to leave it to you? |
I am on it, would love your feedback when I submit a PR. |
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
Would be awesome if there was some documentation regarding setting up an API Gateway with Lambda-Proxy integration with one or more Lambda functions.
The text was updated successfully, but these errors were encountered: