Skip to content

Commit

Permalink
feat(lambda): introduce a new kind of Code, CfnParametersCode. (#…
Browse files Browse the repository at this point in the history
…2027)

This Code type is helpful when there is no local file/directory to use Assets with,
and the Lambda is supposed to be deployed in a CodePipeline.
  • Loading branch information
skinny85 committed Apr 8, 2019
1 parent 0f6ce56 commit 4247966
Show file tree
Hide file tree
Showing 9 changed files with 1,356 additions and 14 deletions.
44 changes: 43 additions & 1 deletion packages/@aws-cdk/aws-codepipeline-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,22 @@ This package defines the following actions:
changes from the people (or system) applying the changes.
* **CloudFormationExecuteChangeSetAction** - Execute a change set prepared previously.
##### Lambda deployed through CodePipeline
If you want to deploy your Lambda through CodePipeline,
and you don't use assets (for example, because your CDK code and Lambda code are separate),
you can use a special Lambda `Code` class, `CfnParametersCode`.
Note that your Lambda must be in a different Stack than your Pipeline.
The Lambda itself will be deployed, alongside the entire Stack it belongs to,
using a CloudFormation CodePipeline Action. Example:
[Example of deploying a Lambda through CodePipeline](test/integ.lambda-deployed-through-codepipeline.lit.ts)
#### AWS CodeDeploy
To use CodeDeploy in a Pipeline:
##### Server deployments
To use CodeDeploy for EC2/on-premise deployments in a Pipeline:
```ts
import codedeploy = require('@aws-cdk/aws-codedeploy');
Expand All @@ -348,6 +361,35 @@ pipeline.addStage({
});
```
##### Lambda deployments
To use CodeDeploy for blue-green Lambda deployments in a Pipeline:
```typescript
const lambdaCode = lambda.Code.cfnParameters();
const func = new lambda.Function(lambdaStack, 'Lambda', {
code: lambdaCode,
handler: 'index.handler',
runtime: lambda.Runtime.NodeJS810,
});
// used to make sure each CDK synthesis produces a different Version
const version = func.newVersion();
const alias = new lambda.Alias(lambdaStack, 'LambdaAlias', {
aliasName: 'Prod',
version,
});

new codedeploy.LambdaDeploymentGroup(lambdaStack, 'DeploymentGroup', {
alias,
deploymentConfig: codedeploy.LambdaDeploymentConfig.Linear10PercentEvery1Minute,
});
```
Then, you need to create your Pipeline Stack,
where you will define your Pipeline,
and deploy the `lambdaStack` using a CloudFormation CodePipeline Action
(see above for a complete example).
#### AWS S3
To use an S3 Bucket as a deployment target in CodePipeline:
Expand Down
Loading

0 comments on commit 4247966

Please sign in to comment.