I have a CDK project where we wrap all our resources in the Pipeline construct. Prior to adding the pipeline, we could run cdk diff locally to view changes to the resources we were deploying. Now that we use the Pipeline construct, running diff's locally only results in changes to the pipeline construct being displayed. Is there any way other fiddling with the pipeline construct to view diff's of the application resources and not the pipeline?
1 Answer
Option 1: diff the Application resources AND the Pipeline resources
The stack specifier **
will return differences for all stacks in the hierarchy, not just the Pipeline itself:
cdk diff '**' -a 'ts-node ./bin/app-pipeline.ts'
Option 2: diff the Application resources only
To exclude differences in your Pipeline stack entirely, first nest the "application' stacks in a new Construct
subclass. See CDK doc's MyService
construct example. MyService
wraps three child "application" stacks:
MyService # Construct
ControlPlane # Stack
DataPlane # Stack
Monitoring # Stack
Then use MyService
in two contexts, your pipeline Stage and App:
# app-pipeline.ts
MyPipeline # Pipeline
MyStage # Stage
MyService # Construct
# app.ts
App # App
MyService # Construct
Running cdk diff --app 'ts-node ./bin/app.ts'
on the App will generate the differences in ControlPlane
, DataPlane
and Monitoring
, not the pipeline itself. These are the same Application differences that will be deployed in the pipeline.
-
Maybe good to point out that you really need the quotes in
'**'
. From the docs: "When using wildcards, enclose the pattern in quotes, or escape the wildcards with \. If you don't, your shell may try to expand the pattern to the names of files in the current directory. At best, this won't do what you expect; at worst, you could deploy stacks you didn't intend to. "– djvgCommented Aug 23 at 10:18