Skip to content

add support for cdk diff #1764

@josefaidt

Description

@josefaidt

Environment information

System:
  OS: macOS 14.5
  CPU: (10) arm64 Apple M1 Pro
  Memory: 159.56 MB / 32.00 GB
  Shell: /opt/homebrew/bin/fish
Binaries:
  Node: 20.15.0 - ~/.local/state/fnm_multishells/82389_1721400785562/bin/node
  Yarn: undefined - undefined
  npm: 10.8.1 - ~/.local/state/fnm_multishells/82389_1721400785562/bin/npm
  pnpm: 9.4.0 - ~/.local/state/fnm_multishells/82389_1721400785562/bin/pnpm
NPM Packages:
  @aws-amplify/backend: 1.0.4
  @aws-amplify/backend-cli: 1.1.0
  aws-amplify: 6.3.8
  aws-cdk: 2.147.2
  aws-cdk-lib: 2.147.2
  typescript: 5.5.3
AWS environment variables:
  AWS_PROFILE = josef
  AWS_REGION = us-east-1
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

After making changes to my personal sandbox and opening a PR to merge to main/production, it would help the review process to better understand resource changes that are being made beyond the backend code diff.

For example,

  1. team member A adds a new Function with access to Data
  2. team member A deploys changes to their sandbox
  3. team member A verifies changes and opens PR
  4. PR check runs and emits diff artifacts
  5. team member B reviews diff artifacts
  6. team member B approves PR and merges to main

this can be a part of check

npx ampx check --diff [--app-id <amplify-app-id>] [--branch <git-branch>]

or on its own

npx ampx diff [--app-id <amplify-app-id>] [--branch <git-branch>]

Currently diffs can be executed by recreating CDK commands

for branch

cdk diff \
  --ci \
  --app "tsx amplify/backend.ts" \
  --output .amplify/artifacts/cdk.out \
  --context amplify-backend-name=main \ # this is your git branch
  --context amplify-backend-namespace=<amplify-app-id> \ # this is your Amplify app ID
  --context amplify-backend-type=branch

for sandbox

cdk diff \
  --ci \
  --app "tsx amplify/backend.ts" \
  --output .amplify/artifacts/cdk.out \
  --context amplify-backend-name=josef \ # this is $(whoami)
  --context amplify-backend-namespace=discord-interactions \ # this is package.json#name
  --context amplify-backend-type=sandbox

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestNew feature or requestp4sandboxRelated to the sandbox experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions