Local development with the aws-cdk

Viewed 3161

Is it possible to deploy to localstack with the aws-cdk? Thought about switching from serverless to the cdk, but could not find any ohter local testing option except aws SAM..

2 Answers

I'm working through the same challenges right now. The way I'm getting by is taking the synthesized CloudFormation template from CDK and loading that into my LocalStack CloudFormation:

$ cdk synth my-stack > my-stack.template.json
$ awslocal cloudformation create-stack --stack-name my-stack --template-body file://./my-stack.template.json

This is working for me with very simple stacks that do not require artifacts/assets. What I'm still working on here is transposing what CDK does internally with S3 bucket based assets as CloudFormation parameters (e.g. Lambda functions, etc.).

Hopefully this gets you down the road a bit. I feel it's the first part of the solution, given what CDK can do today.

I would point you towards the aws-cdk-local package. This allows you to deploy CDK IaC to your localstack. See aws-cdk-local link

Related