Skip to content

Conversation

@sobolk
Copy link
Contributor

@sobolk sobolk commented Sep 17, 2024

Problem

When installed aws-cdk and aws-cdk-lib are not compatible a fault is raised.

Repro.

Create project like and use mismatched CDK versions.

{
  "name": "testapp048",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@aws-amplify/backend": "^1.2.1",
    "@aws-amplify/backend-cli": "^1.2.6",
    "aws-cdk": "2.130.0",
    "aws-cdk-lib": "2.158.0",
    "constructs": "^10.3.0",
    "esbuild": "^0.23.1",
    "tsx": "^4.19.1",
    "typescript": "^5.6.2"
  },
  "dependencies": {
    "aws-amplify": "^6.6.1"
  }
}

Observe
image

Changes

Add mapping and classify as user error.

Validation

  1. Added test.
  2. Manual verification

image

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sobolk sobolk requested a review from a team as a code owner September 17, 2024 22:05
@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2024

🦋 Changeset detected

Latest commit: a49a006

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/backend-deployer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@rtpascual rtpascual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One question, so the only way customers run into this is if they update their package.json? We would have to keep a close eye to make sure this isn't unintentionally changed to have mismatched versions

'aws-cdk@^2',
'aws-cdk-lib@^2',

@sobolk
Copy link
Contributor Author

sobolk commented Sep 17, 2024

LGTM. One question, so the only way customers run into this is if they update their package.json? We would have to keep a close eye to make sure this isn't unintentionally changed to have mismatched versions

'aws-cdk@^2',
'aws-cdk-lib@^2',

The other way would be to surgically npm update aws-cdk-lib without the other one. I.e. they won't get into this situation by following our create flow. The mismatch happens after create flow, by playing with package.json or npm commands.

As for us changing create flow to mismatched versions. This one is tricky to assert because as long as we ^ both versions the npm will install both at latest - which in theory is correct state.
We would grossly mess this up if we skip ^, but this would surface in e2e tests or canaries.

@sobolk sobolk merged commit cbac105 into main Sep 18, 2024
@sobolk sobolk deleted the handle-cdk-mismatch branch September 18, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants