Package support for CDK apps
Describe your idea/feature/enhancement
Package support for CDK apps would help when you use CDK for your landing zone. Unlike normal CDK apps where you use cdk deploy to package and deploy your app. You will run into issues when you want to build generic stacks using CDK and distribute them using the CloudFormation provider in CodePipeline.
In order to do this you need to capture the output, like this cdk synth > template.yml. You can then use the template in the deployment and benefit parallel deployments. (When you have a large organization it could be 500+ accounts, hence deploying in paralel would speed-up the deployment a lot!)
This works fine until you add a Lambda function to your stack. When you do that the code location is replaced with a CfnParameter reference. So running sam build and sam package against this template would not trigger anything because the CodeUri is not pointing to a local folder. When you use the output you don't know the bucket and object path because this is only available when you run the cdk deploy command. (which we try to avoid because it's not in parallel and requires a active CodeBuild session which is expensive)
So it would be great if there is a way to build and package lambda functions in a CDK stack. The current workaround we use is a lvl1 construct that creates an AWS::Serverless::Function resource. But it would be great if you could just package a CDK application directly using SAM. (Or do a cdk synth > template.yml that can be packaged by SAM CLI)
Proposal
I believe the sam local functionality already allows you to read a cdk app for testing the functions. This functionality could be leveraged to do the same for building and packaging cdk apps.
Additional Details
@Nr18 Thanks for the issue and explanation. When designing out the CDK support, we made an explicit decision not to support CDK templates within package and deploy commands. This is to avoid cases were customers do regional config in CDK and do not realize when they do a cdk synth, that will produce a template for a specific region. We would need to revisit this decision and figure out a way to either solve or make sure customers will not hit this issue following the pattern you want.