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

Add reference to TypeScript template #497

Merged
merged 1 commit into from
Jul 29, 2019
Merged

Conversation

fogfish
Copy link
Contributor

@fogfish fogfish commented Jul 27, 2019

I do see some benefits of TypeScript usage for AWS Lambda development. I've backed a TypeScript template function. Just added a reference to list of examples

Then, I'd like to discuss impact of AWS CDK on node-lambda and its future plans. As an example, AWS community shipped a few examples of functions management. node-lambda provides a consistent approach to run/test the function locally before it is deployed to the cloud. AWS CDK missing this support. However, the function configuration is slightly easier with AWS CDK, the config is maintained at single file. What's is your vision towards migration of node-lambda workflows towards AWS CDK?

@DeviaVir DeviaVir merged commit fc9e018 into motdotla:master Jul 29, 2019
@DeviaVir
Copy link
Collaborator

I am not keeping up to date with AWS recently. Can you highlight AWS CDK vs node-lambda differences, pros/cons? Should we stop with node-lambda now AWS CDK is a thing?

@fogfish
Copy link
Contributor Author

fogfish commented Jul 29, 2019

Thank you for merging!

AWS CDK is not yet a game changer but threat is big!

node-lambda is still best tool for lambda deployments. I've been looking to various approaches but finally made decision to adopt your tool into my delivery pipeline. I am also maintaining a serverless solution for Erlang, I've adopted some of node-lambda techniques to my tool as well. I do see following benefits of node-lambda

  1. literally zero configuration, the tool generates all necessary files to specify the cloud environment and supports deployment.
  2. Support for configurable lambda event which makes integration testing easy.
  3. Support for local execution, it simplify development time
  4. Fast deployment

However, the tool suffers support for the big picture. Usually we deploys lambdas together with backing services. It is not enough to provision IAM roles. The application needs to create additional resources. Additionally, my application consists of multiple lambdas (2 - 6). For example in my use-case:

  • create SQS, S3 and lambda
  • create dynamo, rest api (API Gateway) and n lambdas
  • create rest api and n lambdas in VPC
  • create kinesis and lambda

Currently, I am solving this problem using CloudFormation templates. The deployment consists of two phases. Firstly, you deploy backing services using aws cloudformation ... then you deploy lambda with node-lambda. The CloudFormation is done only once but lambda deployments is driven by CI.

CloudFormation is a weak link here. Its development and maintenance is time consuming. AWS CDK resolve this problem. It is extremely easy and fast to develop you backing service. Personally, I am doing to adopt this technology and put CloudFormation on hold.

Unfortunately, the node-lambda configuration is not compatible with AWS CDK. You have to either manage lambdas either with node-lambda or AWS CDK. It becomes easy to integrate lambda with backing service in the cloud - CDK takes care to spawn additional resources. Basically AWS CDK kills 1. and 2. node-lambda is still outperform 3. and 4.

As an example, here is AWS CDK code that spawn REST API with lambda. Just 28 lines of code. Similar feature takes about 100 lines of YAML with CloudFormation.

I hope it shed some lights to you. I am continue my experiments with AWS CDK. I'll keep you posted!

function RestApi(parent: cdk.Construct): cdk.Construct {
  const rest = new api.RestApi(parent, 'WebHook',
    {
      deploy: true,
      deployOptions: {
        stageName: 'api'
      },
      failOnWarnings: true,
      endpointTypes: [api.EndpointType.REGIONAL]
    }
  )

  endpointFriends(rest)

  return rest
}

function endpointFriends(restapi: api.RestApi) {
  const handler = new lambda.Function(restapi, 'WebHookLambda',
    {
      runtime: lambda.Runtime.NODEJS_10_X,
      code: new lambda.AssetCode('../src'),
      handler: 'index.handler'
    }
  )
  restapi.root.addResource('friends').addMethod('POST',
    new api.LambdaIntegration(handler)
  )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants