简体   繁体   中英

Cloud Assembly Schema Version Mismatch - Building A Code Pipeline In The CDK

After following the solution on github , and the solution on Stack Overflow , I am still experiencing the same issue when building a code pipeline with AWS CDK.

Error:

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 21.0.0, but found 22.0.0)

This error appears in the Code Build Stage of the Code Pipeline. Sourcing the code from Code Commit works successfully, as the first stage.

CDK Pipeline Code:

As you can see in the code below, I have the install commands of uninstalling the cdk, and then installing it again. This was the recommended solution provided by the document above. Re-ordering does not influence the outcome.

this.codePipeline = new CodePipeline(this, `${environment}-${appName}-`, {
  pipelineName: `${environment}-${appName}-`,
  selfMutation: true,
  crossAccountKeys: false,
  role: this.codePipelineRole,
  synth: new ShellStep("Deployment", {
    input: CodePipelineSource.codeCommit(this.codeRepository, environment, {
      codeBuildCloneOutput: true
    }),
    installCommands: ["npm uninstall -g aws-cdk", "npm i -g npm@latest", "npm install -g aws-cdk"],
    commands: [
      "cd backend",
      "npm ci",
      "npm run build",
      "npx cdk synth",
    ],
    primaryOutputDirectory: "backend/cdk.out",
  })
});

Dependencies in the package.json file:

  "dependencies": {
    "@aws-cdk/aws-appsync-alpha": "^2.55.1-alpha.0",
    "aws-cdk-lib": "^2.58.0",
    "aws-sdk": "^2.1278.0",
    "constructs": "^10.1.204",
    "git-branch": "^2.0.1",
    "source-map-support": "^0.5.21"
  }

The solution was to do without the npx in npx cdk synth . I removed it and the code worked. This was also experienced when attempting to run npx cdk synth locally.

Solution: cdk synth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM