Welcome to the AWS CDK Diff GitHub Action repository! This GitHub Action automates the process of reviewing infrastructure changes in AWS Cloud Development Kit (CDK) projects by using the cdk diff command. It aims to enhance pull request reviews by providing a clear and concise summary of proposed infrastructure changes.
This action runs cdk diff on AWS CDK projects for each pull request, processes the output for readability, and posts it as a comment on the pull request. This facilitates informed and efficient review processes by providing immediate insights into the impact of proposed changes on AWS infrastructure.
Most of the template for the action was taken from here and the general idea taken from here, credit to them.
Refer to the actions.ymlfor detailed configuration options.
- uses: 0xdsqr/cdk-diff-action@v0.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}# Example of referencing the output from the action
- name: Use My Action
id: myaction
uses: 0xdsqr/cdk-diff-action@v0.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Use Output
run: echo "The output was ${{ steps.myaction.outputs.cdkOutPutPath }}"For version 1, ensure your CI is set up with AWS credentials and the AWS CDK before calling cdk-diff-action.
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: |
python -m pip install --upgrade pip
npm install -g aws-cdk
- uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: "us-east-1"
- uses: 0xdsqr/cdk-diff-action@v0.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}- Automated Diff Summary: Runs cdk diff for pull requests and provides a readable summary.
- Clean and Clear Output: Formats the cdk diff output in Markdown for better readability.
- Enhanced Review Process: Posts the diff summary directly on pull requests for easy access.
- Detection of Critical Changes: Highlights significant changes and potential risks.
- Efficient Output Management: Ensures the comment size is within GitHub's constraints.
The action comprises several key functions:
- Reading and Cleaning Output: Reads the cdk diff output file, cleans it of ANSI escape codes, and converts it into a Markdown-friendly format.
- Processing Differences: Identifies the number of stacks with differences and resources requiring replacement, providing a concise summary at the top of the comment.
- Commenting on Pull Requests: Utilizes the GitHub API to post the processed cdk diff output as a comment on the relevant pull request.
See some example diff audits below.
