aws-samples / serverless-patterns

Serverless patterns. Learn more at the website: https://serverlessland.com/patterns.
https://serverlessland.com
Other
1.48k stars 863 forks source link

New pattern submission - apigw-http-api-lambda-ts-cdk #2202

Closed philippewanner closed 1 month ago

philippewanner commented 2 months ago

apigw-http-api-lambda-ts-cdk

Description

This pattern create an Amazon API Gateway HTTP API and a dummy Lambda function returning a simple "Hello World".

Language

Node.js (Typescript)

Framework

CDK

Service from/to

Service from: API Gateway HTTP API (v2) Service to: Lambda

Description

This pattern creates an Amazon API Gateway HTTP API (v2) that integrates with an AWS Lambda function by using AWS Cloud Development Kit (AWS CDK).

Amazon API Gateway HTTP API is designed with minimal features so it can be offered at a lower price than the REST API. For more information, please read the official document Choosing between REST APIs and HTTP APIs.

This pattern deploys a API Gateway HTTP API that is responsible to route the root path ("/") to the AWS Lambda function. The function (called 'dummy') return a 200 HTTP code and "Hello World" payload to the caller.

The template includes a CDK stack a HTTP API and a Lambda resources. The stack will output the HTTP API URL after the deployment, so you can test the API.

Deployment commands

npm run deploy

GitHub PR for template:

https://github.com/aws-samples/serverless-patterns/pull/2199

Payload example (e.g. Lambda event payload from source service).

N/A

Additional resources (optional: link and anchor text, up to 5 resources)

[Working with the AWS CDK in TypeScript](https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-typescript.html)
[Working with HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html)
[Building Lambda functions with TypeScript](https://docs.aws.amazon.com/lambda/latest/dg/lambda-typescript.html)

Author bio

Name: Philippe Wanner Photo URL: https://www.linkedin.com/in/philippe-wanner/ LinkedIn: https://www.linkedin.com/in/philippe-wanner/ Twitter handle: n/a Description (up to 255 chars): Philippe is a Senior Specialist Solutions Architect at Amazon Web Services based in Zurich, Switzerland. His role is to spread the migration and modernization best practices for large organisations. Follow on LinkedIn