How to create and deploy Lambda function on AWS with CDK and API endpoint to Lambda

Click for: original source

Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted scaleable cloud platform. AWS offering over 200 fully featured services from data centers globally. This tutorial will teach you how to create serverless function in Typescript and deploy it to AWS. By Abdul Waqar.

import * as cdk from "@aws-cdk/core";
import * as lambda from "@aws-cdk/aws-lambda";
import * as apigw from "@aws-cdk/aws-apigateway";

export class HelloLambdaStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    const hello = new lambda.Function(this, "HelloHandler", {
      runtime: lambda.Runtime.NODEJS_10_X,
      code: lambda.Code.fromAsset("lambda"),
      handler: "hello.handler",
    });

  }
}

The article then in brief steps describes:

  • What is AWS and CDK?
  • Lambda Function
  • Amazon API Gateway
  • Lets write code for Lambda Function
  • Deploy Lambda Function using CDK

Congratulation! You have successfully deployed your first Lambda Function and API Gateway to call Lambda Function on AWS Cloud. Good read!

[Read More]

Tags app-development devops cloud open-source serverless