You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Github Actions突发失败:AWS Cloud Assembly Schema版本不匹配求助

AWS CDK CLI与库版本不兼容导致Github Action部署失败

我的Github Action此前正常运行数百次,昨日突然失败,重新运行过往成功的任务也会失败。推测问题可能和AWS的某次更新有关,寻求解决办法。

错误信息

This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version. (Cloud assembly schema version mismatch: Maximum schema version supported is
38.x.x, but found 39.0.0) Error: Process completed with exit code 1.

参考工作流文件

on:
  push:
    branches:
      - develop

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "20"

      - name: Install dependencies
        run: |
          npm install -g yarn
          yarn
      - name: Install stable version of AWS CDK
        run: npm install -g aws-cdk@2.166.0

      - name: Deploy to AWS (xxx)
        run: |
          cd infrastructure
          yarn
          npx cdk bootstrap --all -c env=xxx aws://$BETA_ACCOUNT_ID/us-west-1
          npx cdk deploy -c env=xxx --require-approval never --all
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.xxx }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.xxx }}
          AWS_DEFAULT_REGION: us-west-1
          BETA_ACCOUNT_ID: ${{ secrets.xxx }}

解决方法

  • 统一CDK版本:错误核心是CLI版本(2.166.0)对应的Schema版本低于项目依赖的CDK库版本。先查看infrastructure/package.json中@aws-cdk/*系列依赖的版本,将CLI安装版本改为和依赖一致的版本,比如如果依赖是2.167.0,就把npm install -g aws-cdk@2.166.0改成npm install -g aws-cdk@2.167.0。
  • 锁定依赖版本:在项目的package.json中明确指定CDK相关依赖的固定版本(去掉^或~前缀),同时在执行yarn时添加--frozen-lockfile参数,强制使用lock文件中的版本,避免依赖自动升级:
    yarn --frozen-lockfile
    
  • 检查依赖安装逻辑:确保项目依赖安装时不会自动拉取未锁定的高版本CDK库,优先使用lock文件中记录的稳定版本。

内容的提问来源于stack exchange,提问作者Haroldo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 03:25:58