-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-cdk: cx-api installed twice by NPM #17974
Comments
Here is the patch I did: function isAssetManifestArtifact(art) {
+ return art.constructor.name === 'AssetManifestArtifact';
- return art instanceof cxapi.AssetManifestArtifact;
} I could send a pull request, but I'm not sure:
|
I have opened #19511 to fix this because this is a huge blocker. Again, this happens when package.json requires: {
"dependencies": {
"aws-cdk": "^2.1.0",
"aws-cdk-lib": "^2.1.0"
}
} |
There's the rub. We don't support doing this. If you use the CLI as intended, this problem will not occur. |
Fixes aws#17974 Inspired from aws/constructs#955
Fixes aws#17974 Inspired from aws/constructs#955
Fixes aws#17974 Inspired from aws/constructs#955
Fixes aws#17974 Inspired from aws/constructs#955
Fixes aws#17974 Inspired from aws/constructs#955
Fixes aws#17974 Inspired from aws/constructs#955
Fixes #17974 Follow-up of #14468 This follows the implementation of aws/constructs#955 to be more robust. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Fixes aws#17974 Follow-up of aws#14468 This follows the implementation of aws/constructs#955 to be more robust. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
What is the problem?
When requiring
aws-cdk
andaws-cdk-lib
in a project, then thecx-api
package gets installed twice:aws-cdk
aws-cdk-lib
That causes a problem similar to #14468 because of this bit:
aws-cdk/packages/aws-cdk/lib/api/cloudformation-deployments.ts
Lines 328 to 330 in 4e7a275
The
instanceof
fails because of the class duplication (again, similar thing happened in #14468, see this comment: #14468 (comment)).I signaled this with CDK v1 here: #14468 (comment) but the same problem happens with CDK v2.
Note: I am requiring both of those package to deploy with the CDK programmatically, not deploying via the CLI. BTW let me know if that is completely not meant to be done that way.
Reproduction Steps
Package.json:
JS file:
What did you expect to happen?
isAssetManifestArtifact()
should return true. And the deployment should succeed.What actually happened?
isAssetManifestArtifact()
returns false, caused some assets not to be uploaded to S3 (namely the CloudFormation template).That causes the deployment to fail because the CloudFormation deployment is looking for a template on S3 that doesn't exist (it was never uploaded there).
CDK CLI Version
Not using the CDK CLI
Framework Version
No response
Node.js Version
17.0.1
OS
macOS
Language
Typescript
Language Version
4.1.2
Other information
I have no idea how we could make that
instanceof
more robust.BUT even if we did, what if there are other
instanceof
tests in the codebase? (#14468 tells us that this isn't an isolated problem)Maybe we should fix the root problem: how can we make sure cx-api (or any other dependency) is installed once in projects that require
aws-cdk
andaws-cdk-lib
?The text was updated successfully, but these errors were encountered: