Closed smaud closed 1 year ago
aws-lambda-nodejs module documentation provides comprehensive example how to setup function: https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html
Pipeline example can then be ammended to use aws-lambda-nodejs.NodejsFunction
instead of lambda.Function
. It is also likely you wont need to have a separate Lambda build step, but I haven't tried it myself
Unfortunately the Pipeline example uses the code property of lambda, whereas aws-lambda-nodejs does not have this property and expects a file. If you have an example showing how to put aws-lambda-nodejs into a blue/green CI/CD please post it. Thanks! :)
I don't have example at hand, but did you try to replace these in lib/lambda-stack.ts
:
this.lambdaCode = lambda.Code.fromCfnParameters();
const func = new lambda.Function(this, 'Lambda', {
code: this.lambdaCode,
handler: 'index.main',
runtime: lambda.Runtime.NODEJS_10_X,
description: `Function generated on: ${new Date().toISOString()}`,
});
const alias = new lambda.Alias(this, 'LambdaAlias', {
aliasName: 'Prod',
version: func.currentVersion,
});
With:
const func = new lambda.NodejsFunction(this, 'MyFunction', {
entry: '/path/to/my/file.ts', // accepts .js, .jsx, .ts and .tsx files
handler: 'myExportedFunc'
});
const alias = new lambda.Alias(this, 'LambdaAlias', {
aliasName: 'Prod',
version: func.currentVersion,
});
As for how to implement Blue/Green deployments with CodePipeline, I think this is more of a question for amazon forum, reddit or support as it is not related to CDK directly.
Yes I did - but how do you get the path to the file if it hasn't been built yet by codebuild??
My understanding is that it "builds" it for you, that is code resides somewhere within CDK app and aws-lambda-nodejs
takes care of packaging it as a zip file and creating Lambda function for you
how would you do blue/green codedeploy?
Mr Sholto Maud
That's more of a codepipeline question, rather than CDK, I dont use former so can't help much. Maybe other CDK users can share their experience.
Nah, definitely a CDK question.
You need CDK CI/CD to deploy nodejs lambda blue/green.
This issue hasn't received any activity in a long time. If there are still requests an example then I suggest creating an issue or PR in this repository: https://github.com/aws-samples/aws-cdk-examples/issues.
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
@sholtomaud Did you find a solution for this yet? Facing a similar problem, where I want to setup a CI/CD Pipeline where in the deploy stage a lambda Function should be deployt from code which is being build the step before and put into an artifact.
Yes I did. I don't have the code on me however.
I also can't find an example of how to create a CI/CD pipeline with @aws-cdk/aws-lambda-nodejs module. If someone has a link to a resource that explains it, could you please share it?
AWS need to lift their game, its their product.
:question: General Issue
The Question
aws-lambda-nodejs does not have an example of integration with CI/CD and codeDeploy blue/green/canary pipeline.
Lambda example (https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html?shortFooter=true) requires a Lambda property of
code
to be present but this is not presented on aws-lambda-nodejs.Please provide similar example.
Environment
Other information