I am trying with AWS CDK to deploy few lambdas. Code pasted below created a Serverless application also a newly created role associated. But for my use case only standalone functions are required. So.. is there any option in CDK API to create only the function (not lambda application). Could you share your suggestion or experience on this?
new lambda.Function(this, 'History', {
functionName: 'History',
code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/getHistory')),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
environment: {
---;
},
timeout: cdk.Duration.seconds(120),
description: '---',
// role:
});
I missed to update on this. Based on the reply from aws support "Standalone lambda function alone (without Lambda application) can not be created by using CDK & CloudFormation. So, either AWS Console or AWS CLI has to be used".
Pasting extracted content, "From your latest correspondence, a standalone lambda function can be created using the CDK & CloudFormation however, a Lambda application is also created that contains any relevant resources that work with your Lambda function. As previously discussed, this does not change the way in which you interact with a Lambda function that you deploy using the CDK and CloudFormation as you will see the standalone Lambda functions in your AWS Lambda Console.
If you would like to create the function without creating a Lambda application, you can look at creating a function using the AWS Console or AWS CLI [1]. "