-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
chore(kms): cross-stack usage detection depends on NPM tree #15580
Conversation
KMS keys try to be smart about not generating impossible dependencies between multiple stacks, which CodePipeline takes advantage of for its support stacks. However, because the logic that tests for this case has an `instanceof Construct` in its code path, if there are ever multiple copies of the `constructs` library in the NPM tree the test will fail, and the resulting error will be very confusing. This situation can arise when people flip back and forth between CDK v1 and v2, because `package-lock.json` will contain half-baked dependency trees; people will be looking at their code but the issue will be in invisible state. Be more liberal in detecting that a construct is, in fact, a construct to get around this.
packages/@aws-cdk/aws-kms/lib/key.ts
Outdated
* multiple copies of the `constructs` library on disk. This can happen | ||
* when upgrading and downgrading between v2 and v1, and in the use of CDK | ||
* Pipelines is going to an error that says "Can't use Pipeline/Pipeline/Role in | ||
* a cross-environment fahsion", which is very confusing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fashion
packages/@aws-cdk/aws-kms/lib/key.ts
Outdated
function isConstruct(x: any): x is Construct { | ||
const sym = Symbol.for('constructs.Construct.node'); | ||
return (typeof x === 'object' && x && | ||
(x instanceof Construct // happy fast case | ||
|| !!(x as Construct).node // constructs v10 | ||
|| !!(x as any)[sym])); // constructs v3 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how production software looks like!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this to the constructs
library? Feels like it might be a better place to put this code, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure. Don't forget to add it to both versions :)
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
KMS keys try to be smart about not generating impossible dependencies between multiple stacks, which CodePipeline takes advantage of for its support stacks. However, because the logic that tests for this case has an `instanceof Construct` in its code path, if there are ever multiple copies of the `constructs` library in the NPM tree the test will fail, and the resulting error will be very confusing. This situation can arise when people flip back and forth between CDK v1 and v2, because `package-lock.json` will contain half-baked dependency trees; people will be looking at their code but the issue will be in invisible state. Be more liberal in detecting that a construct is, in fact, a construct to get around this. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
KMS keys try to be smart about not generating impossible dependencies between multiple stacks, which CodePipeline takes advantage of for its support stacks. However, because the logic that tests for this case has an `instanceof Construct` in its code path, if there are ever multiple copies of the `constructs` library in the NPM tree the test will fail, and the resulting error will be very confusing. This situation can arise when people flip back and forth between CDK v1 and v2, because `package-lock.json` will contain half-baked dependency trees; people will be looking at their code but the issue will be in invisible state. Be more liberal in detecting that a construct is, in fact, a construct to get around this. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
KMS keys try to be smart about not generating impossible dependencies
between multiple stacks, which CodePipeline takes advantage of for
its support stacks.
However, because the logic that tests for this case has an
instanceof Construct
in its code path, if there are ever multiple copies of theconstructs
library in the NPM tree the test will fail, and theresulting error will be very confusing.
This situation can arise when people flip back and forth between
CDK v1 and v2, because
package-lock.json
will contain half-bakeddependency trees; people will be looking at their code but the issue
will be in invisible state.
Be more liberal in detecting that a construct is, in fact, a construct
to get around this.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license