@@ -324,9 +324,22 @@ This package defines the following actions:
324
324
changes from the people (or system) applying the changes.
325
325
* **CloudFormationExecuteChangeSetAction** - Execute a change set prepared previously.
326
326
327
+ ##### Lambda deployed through CodePipeline
328
+
329
+ If you want to deploy your Lambda through CodePipeline,
330
+ and you don't use assets (for example, because your CDK code and Lambda code are separate),
331
+ you can use a special Lambda ` Code ` class, ` CfnParametersCode ` .
332
+ Note that your Lambda must be in a different Stack than your Pipeline.
333
+ The Lambda itself will be deployed, alongside the entire Stack it belongs to,
334
+ using a CloudFormation CodePipeline Action. Example:
335
+
336
+ [Example of deploying a Lambda through CodePipeline](test/integ.lambda-deployed-through-codepipeline.lit.ts)
337
+
327
338
#### AWS CodeDeploy
328
339
329
- To use CodeDeploy in a Pipeline:
340
+ ##### Server deployments
341
+
342
+ To use CodeDeploy for EC2/on-premise deployments in a Pipeline:
330
343
331
344
` ` ` ts
332
345
import codedeploy = require (' @aws-cdk/aws-codedeploy' );
@@ -348,6 +361,35 @@ pipeline.addStage({
348
361
});
349
362
` ` `
350
363
364
+ ##### Lambda deployments
365
+
366
+ To use CodeDeploy for blue-green Lambda deployments in a Pipeline:
367
+
368
+ ` ` ` typescript
369
+ const lambdaCode = lambda .Code .cfnParameters ();
370
+ const func = new lambda .Function (lambdaStack , ' Lambda' , {
371
+ code: lambdaCode ,
372
+ handler: ' index.handler' ,
373
+ runtime: lambda .Runtime .NodeJS810 ,
374
+ });
375
+ // used to make sure each CDK synthesis produces a different Version
376
+ const version = func .newVersion ();
377
+ const alias = new lambda .Alias (lambdaStack , ' LambdaAlias' , {
378
+ aliasName: ' Prod' ,
379
+ version ,
380
+ });
381
+
382
+ new codedeploy .LambdaDeploymentGroup (lambdaStack , ' DeploymentGroup' , {
383
+ alias ,
384
+ deploymentConfig: codedeploy .LambdaDeploymentConfig .Linear10PercentEvery1Minute ,
385
+ });
386
+ ` ` `
387
+
388
+ Then, you need to create your Pipeline Stack,
389
+ where you will define your Pipeline,
390
+ and deploy the ` lambdaStack ` using a CloudFormation CodePipeline Action
391
+ (see above for a complete example).
392
+
351
393
#### AWS S3
352
394
353
395
To use an S3 Bucket as a deployment target in CodePipeline:
0 commit comments