DEV Community

Discussion on: ⚡️Combining Serverless Framework & AWS CDK

Collapse
 
fredericbarthelet profile image
Frédéric Barthelet AWS Community Builders • Edited

Nice article ! Thanks for sharing.
In addition, if your CDK stack does not require any assets to be uploaded (understand does not contain any lambda, which should be taken care of by Serverless framework definition), you can use CDK programmatic API synth to inject generated Cloudformation resources directly within the resources key of your serverless.yml file. You then only need to run sls deploy to deploy both Serverless framework resources and CDK resources. Take a look at twitter.com/bartheletf/status/1382... to know more !

Collapse
 
tastefulelk profile image
Sebastian Bille AWS Community Builders

Ooh, that's a great point I didn't consider! It does make it a bit simpler but you also lose a few of the benefits of having the separate stacks and being able to cdk diff for example, I suppose.

Thanks for the tip! 🙌

Collapse
 
adityanair102001 profile image
AdityaNair102001

Hi @Frédéric, excellent idea but I had a question:
What if the exported values are tokens? Cause the token values are alloted actual values only after deployment through cdk.

Collapse
 
fredericbarthelet profile image
Frédéric Barthelet AWS Community Builders

Hi @adityanair102001 , I wrote an article to explain in more detail what can be achieved in terms of CDK provisioning through Serverless framework lifecycle. You can have a look at dev.to/kumo/serverless-framework-a... to learn more. Token can be resolved using the resolve API available on the CDK stack :)