Aws-cdk: CLI and Framework compatibility - confusing error message

Created on 11 May 2020  路  12Comments  路  Source: aws/aws-cdk

When using framework version 1.38.0 with CLI version 1.36.0, running cdk synth throws
the following error:

Cloud assembly schema version mismatch: Maximum schema version supported is 1.33.0, 
but found 2.0.0. Please upgrade your CLI in order to interact with this app.

While it's clear to me that I need to upgrade the CLI version, I see two problems with this error message:

  1. ~This is probably a bug, but it seems like the check compares two different things as the versions compared are off by a major version, 2.0.0 and 1.33.0.~ This is not a bug there was a major version bump of the scheme.
  2. The use of the term Cloud assembly in such a basic functionality of the CDK seems like it can be confusing for many users. While the term is well defined in the CDK documentation I don't think it's common among users. Since the action required from the user is to update the CLI I don't see the added a value of using Cloud assembly in here.

Most helpful comment

~Excuse my ignorance on this one but have just hit this error message and can't seem to figure out which version this is referring to and what needs to be upgraded. Does anyone have the fix for this?~
Was being a noob, run npm install -g aws-cdk to upgrade the CDK CLI.

All 12 comments

@iliapolo

~Excuse my ignorance on this one but have just hit this error message and can't seem to figure out which version this is referring to and what needs to be upgraded. Does anyone have the fix for this?~
Was being a noob, run npm install -g aws-cdk to upgrade the CDK CLI.

I'm experiencing this as well and it started just a few days ago. It happens in my CI pipeline. I'll be investigating today but below are some details for anybody else who comes across this ticket.

I suspect this is an issue with CDK because:

  • We only added a CDK deployment to our CI a week ago and it was working fine
  • No changes have been made to CI in the last few days
  • We use a bot to auto-update dependencies and CDK has been updated multiple times between the last success and today

Environment

CI Environment: Gitlab, using gitlab-runner 12.10.0-rc2 (6c8c540f)
Docker Image: node:lts (12 at the time of writing)
npm: 6.14.5
cdk version: 1.38.0

Commands executed in CI to produce the error

 $ npm i -g npm
 $ npm config set prefix /usr/local
 $ npm config set cache .npm
 $ npm config set prefer-offline true
 $ export AWS_ACCESS_KEY_ID=$CI_DEPLOY_ACCESS_KEY_ID
 $ export AWS_SECRET_ACCESS_KEY=$CI_DEPLOY_SECRET_ACCESS_KEY
 $ npm i -g aws-cdk
 $ npm ci
 $ cdk deploy --ci --require-approval=never

 Cloud assembly schema version mismatch: Maximum schema version supported is 1.33.0, but found 2.0.0.
 Please upgrade your CLI in order to interact with this app.

@baer since you execute npm install -g aws-cdk before executing cdk deploy your CLI version should be compatible with the framework version. Can you execute cdk --version after executing npm install -g aws-cdk to verify you have the latest version installed?

@NetaNir Agreed, it should, but it looks like the version is 1.36.1 which is... odd. This points to a problem with either Gitlab's CI, Gitlab's CI caching, or pm resolving the wrong version.

 $ npm i -g aws-cdk
 /usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk
 + [email protected]
 added 213 packages from 187 contributors in 5.208s

I'm going to clear the cache and see what I can learn.

@NetaNir I re-ran the CI job with the --prefer-online flag which forces a cache invalidation in NPM and got the same result:

 $ npm i -g aws-cdk --prefer-online
 /usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk
 + [email protected]
 added 213 packages from 187 contributors in 6.908s

When I removed the cache altogether, I got the latest version. You could also use npm install --force to do the same thing.

 $ npm i -g aws-cdk --prefer-online
 /usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk
 + [email protected]
 added 213 packages from 187 contributors in 8.379s

The issue appears to be that NPM is checking for semver major on npm install and that the cached 1.26.1 satisfies that constraint. It looks like aws-cdk released a breaking change in a semver minor release which could be problematic for others as well depending on how you specify the dependency in the package.json. See npm-semver for details

@NetaNir you can try to reinstall cdk.
npm uninstall -g cdk
and then
npm install -g aws-cdk

Please make sure if aws-cdk dependency is pointing to the right cdk version in the package.json file. If not, please run npm install [email protected]

Ran into this issue and fixed this issue as well today. We had a rouge cdk dependency pointing to 1.37 instead of 1.38.

Our fix for this was ensuring that all dependencies (including types) match the version of aws-cdk.

COMMANDS:
pip install --upgrade awscli
And then
npm -g update aws-cdk
SOLVE THE PROBLEM.

npm install -g aws-cdk works for me , Fixed this issue

Let's change the message to:

You are using a CDK CLI version which is older than CDK version used by your app. Please upgrade your CLI to the latest version (or to a version which supports cloud assembly schema version 3.0.0 or above).
Was this page helpful?
0 / 5 - 0 ratings

Related issues

abelmokadem picture abelmokadem  路  3Comments

eladb picture eladb  路  3Comments

peterdeme picture peterdeme  路  3Comments

eladb picture eladb  路  3Comments

v-do picture v-do  路  3Comments