Skip to content

Conversation

@corymhall
Copy link
Owner

This PR refactors the diff and assembly processing to use the new
@aws-cdk/toolkit-lib library.

This allows us to greatly simplify the logic that we have to maintain
and offload more work to the core library.
For example, this allows us to use the default CDK authentication
instead of trying to replicate it ourselves (see #62).

Couple of other changes that I've included in this PR since v2 allows me
a chance to make breaking changes.

BREAKING CHANGE: several breaking changes with details below

There are several breaking changes in this release.

  1. Replace noDiffForStages with stackSelectionStrategy &
    stackSelectorPatterns
    This uses the native selection stack filtering capability of
    toolkit-lib and should be a more robust option for users to filter
    stacks. stackSelectorPatterns also uses a multi-line input instead of
    a comma delimited string input. To migrate from noDiffForStages to
    stackSelectorPatterns you can do this:
# from this
- name: Diff
   uses: corymhall/cdk-diff-action@v1
   with:
     noDiffForStages: "Stage1,Stage2"
     githubToken: ${{ secrets.GITHUB_TOKEN }}

# to this
- name: Diff
   uses: corymhall/cdk-diff-action@v2-beta
   with:
     stackSelectorPatterns: |
       !Stage1/*
       !Stage2/*
     githubToken: ${{ secrets.GITHUB_TOKEN }}
  1. The default diffMethod is changed to change-set to match the cdk
    default behavior. This also changes the IAM Role used for diff from the
    lookup-role to the deploy-role. To keep the old behavior you can
    specify diffMethod: template-only
  2. allowDestroyTypes and noFailOnDestructiveChanges input types were
    changed from a comma delimited string to a multi-line string.
# from this
- name: Diff
   uses: corymhall/cdk-diff-action@v1
   with:
     noFailOnDestructiveChanges: "Stage1,Stage2"
     githubToken: ${{ secrets.GITHUB_TOKEN }}

# to this
- name: Diff
   uses: corymhall/cdk-diff-action@v2-beta
   with:
     noFailOnDestructiveChanges: |
       Stage1
       Stage2
     githubToken: ${{ secrets.GITHUB_TOKEN }}

Closes #44
Fixes #62


Signed-off-by: github-actions github-actions@github.com
Co-authored-by: github-actions github-actions@github.comFixes #

@corymhall corymhall enabled auto-merge (squash) June 20, 2025 09:22
corymhall and others added 6 commits June 20, 2025 05:48
This PR refactors the diff and assembly processing to use the new
`@aws-cdk/toolkit-lib` library.

This allows us to greatly simplify the logic that we have to maintain
and offload more work to the core library.
For example, this allows us to use the default CDK authentication
instead of trying to replicate it ourselves (see #62).

Couple of other changes that I've included in this PR since v2 allows me
a chance to make breaking changes.

BREAKING CHANGE: several breaking changes with details below

There are several breaking changes in this release.
1. Replace `noDiffForStages` with `stackSelectionStrategy` &
`stackSelectorPatterns`
This uses the native selection stack filtering capability of
`toolkit-lib` and should be a more robust option for users to filter
stacks. `stackSelectorPatterns` also uses a multi-line input instead of
a comma delimited string input. To migrate from `noDiffForStages` to
`stackSelectorPatterns` you can do this:
```yaml
- name: Diff
   uses: corymhall/cdk-diff-action@v1
   with:
     noDiffForStages: "Stage1,Stage2"
     githubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Diff
   uses: corymhall/cdk-diff-action@v2-beta
   with:
     stackSelectorPatterns: |
       !Stage1/*
       !Stage2/*
     githubToken: ${{ secrets.GITHUB_TOKEN }}
```
2. The default `diffMethod` is changed to `change-set` to match the cdk
default behavior. This also changes the IAM Role used for diff from the
`lookup-role` to the `deploy-role`. To keep the old behavior you can
specify `diffMethod: template-only`
3. `allowDestroyTypes` and `noFailOnDestructiveChanges` input types were
changed from a comma delimited string to a multi-line string.
```yaml
- name: Diff
   uses: corymhall/cdk-diff-action@v1
   with:
     noFailOnDestructiveChanges: "Stage1,Stage2"
     githubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Diff
   uses: corymhall/cdk-diff-action@v2-beta
   with:
     noFailOnDestructiveChanges: |
       Stage1
       Stage2
     githubToken: ${{ secrets.GITHUB_TOKEN }}
```

Closes #44
Fixes #62

---------

Signed-off-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
This adds two new inputs to the action.

1. `title` an optional title to include with each stage comment
2. `defaultStageDisplayName` an optional name to use for the default
   stage instead of `DefaultStage`

closes #130

---------

Signed-off-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
This upgrades toolkit-lib to the latest version which fixes the libCheck
typechecking. In the latest version toolkit-lib also updates the diff to
use the stack display name instead of the name/id so this updates the
action to also use the display name.
This is the first step in attempting to solve the case when diff
comments are too long. From testing it looks like the comment limit that
the API returns (65535) is not the real limit, but it is hard to find
any concrete information on what the real limit is. I was able to post
some comments with a length > 150000.

Instead of doing any validation on our end and failing early, this PR
updates the logic to rely on the GH API failure message. We will always
attempt to comment and catch any "Body too long" errors that occur.

This should increase the size of the comment allowed and may fix the
issue for some users. I will follow up this with additional PRs fixing
the issue completely.

re #34
Add ISO formatted timestamp to PR comments. 

fixes #132
@corymhall corymhall disabled auto-merge June 20, 2025 11:56
@corymhall corymhall merged commit bef9679 into main Jun 20, 2025
4 checks passed
@corymhall corymhall deleted the v2-beta branch June 20, 2025 11:57
@corymhall corymhall restored the v2-beta branch June 20, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to assume CDK lookup role using temporary session credentials Support diffForStages and failOnDestructiveChanges

3 participants