user1584120
user1584120

Reputation: 1261

What are the differences in lambdas created by aws-cdk in the different packages?

In aws_cdk there are three different classes for creating lambdas: aws_cdk.aws_lambda.CfnFunction
aws_cdk.aws_lambda.Function
aws_cdk.aws_sam.CfnFunction
What are the differences and reasons for choosing one over the other?

Upvotes: 3

Views: 1321

Answers (2)

Adam Ruka
Adam Ruka

Reputation: 136

Our documentation deals with this subject: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib

Upvotes: 0

Jonny Rimek
Jonny Rimek

Reputation: 1171

For every AWS Resource that is supported by CloudFormation there are always two classes. The Cfn version maps directly to what you would normally do in YAML. The other version, in this case aws_lambda.Function, is a higher level class that already sets useful default values to get up and running faster. e.g. memorySize and timeout.

I'm not completely sure about the aws_sam thing, but I wouldn't recommend using it as the libary is not stable and you can achieve the same thing without this libary.

e.g. https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/api-cors-lambda-crud-dynamodb

Upvotes: 1

Related Questions