The CDK Changeset Reporter is a Python script that collects and prints CloudFormation (CFN) changeset information for one or more AWS Cloud Development Kit (CDK) stacks in a Cloud Assembly folder. The reporter uses each stack's CDK lookup role as defined in the Cloud Assembly entry for the stack to access the changeset information.
The creation of the changeset(s) is out of scope and the changeset name must be provided to the tool. A typical workflow that prepares a changeset and passes it to the reporter may look like this:
CHANGESET_NAME=FEATURE-123-changes
cdk deploy --all --method prepare-change-set --change-set-name $CHANGESET_NAME
# report on all stacks in the cloud assembly folder
python3 -m cdk_changeset_reporter -n $CHANGESET_NAME
The CDK Changeset Reporter can be used in three ways:
- Create an instance of the
CdkChangesetReporter
class, providing:
- the path to the Cloud Assembly directory (default is
"cdk.out"
). - the name of the CloudFormation changeset to report on.
reporter = CdkChangesetReporter(cloud_assembly_dir="/path/to/cloud_assembly_dir", change_set_name="my-changeset")
- Add stacks to be included in the report using
add_stacks
method. This argument can be an exact name match, name prefix or*
( to match all stacks in the cloud assembly foldler)
reporter.add_stacks("MyStack")
reporter.add_stacks("Other")
- Gather changes for the selected stacks using the
gather_changes
method.
changes = reporter.gather_changes()
- Generate and print the reports for each stack using the
report
method.
reporter.report(changes)
You can combine the steps from Method 1 into a single function call.
reporter.gather_and_report("MyStack")
Replace "MyStack"
with the desired stack name / prefix.
You can execute the module in a CDK project directory with one or more stack prefixes as arguments.
puthon3 -m cdk_changeset_reporter --stacks MyStack Other -n $CHANGESET_NAME
This script is licensed under the Apache License.
This script is provided as-is and without warranty. Use it at your own risk. Always review the changesets before applying them to your stacks.
Note: The script may depend on external libraries and AWS services, which may have their own licenses and terms of use. Please review and comply with the respective licenses and terms.