Serverless CDK Plugin
Currently, It's very hard to describe complex AWS Resources/Infrastructure in your serverless.yml
. This plugin allows you to combine your serverless.yml
with complex infrastructure stacks you define using the AWS Cloud Development Kit.
Installing
Add this package to your project's development dependencies:
$ yarn add --dev serverless-cdk-plugin
$ npm install --save-dev serverless-cdk-plugin
After installing, add this plugin to your serverless.yml
:
plugins: - serverless-cdk-plugin
Usage
This plugin works by spawning the cdk synthesize
command in the current working directory to synthesize your cdk application. The synthesized cloudformation stack is then merged into the serverless cloudformation stack before it is deployed.
CDK Application Definition
There are currently two restrictions on how you define your aws-cdk stack so that it can be used with this plugin:
- you must define the cdk
app
in thecdk.json
file - your cdk
app
must only create one stack.
context
to your aws-cdk stack
Passing runtime You can pass any amount of runtime context to your aws-cdk stack by adding the following to your serverless.yml
:
...custom: CdkResources: context: stage: ${self:provider.stage} myContext: someContextValue
Examples
Check out the examples directory to see example usage patterns.
Current Known Limitations
-
This plugin assumes that your cdk-app only defines one cloudformation stack
-
This plugin will not build/bundle any artifacts with the serverless project to be deployed (for example, you cannot specify a lambda function in your cdk stack)
-
This plugin will not attempt to resolve Resource Logical Id Naming conflicts