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-lib): Aspects doesn't pick up resources that have been symlinked #18778
Comments
Hi, I recently ran into this problem and conducted a very similar test:
I've discovered that the Aspect does actually visit all resources, but the 'instanceof' always evals to false if the construct was created in another library in my lerna monorepo. |
I was able to successfully run my test with expected results (node instanceof CfnResource evals to true) by pushing my shared libs from my mono repo into proper NPM packages (instead of relying on symlinks created by lerna bootstrap). |
When construct libraries are purposely symlinked (as opposed of collectively `npm install`ed), depending on how this is done they may end up with multiple copies of `aws-cdk-lib`. If that happens, Aspects from a different `aws-cdk-lib` copy than the one providing `App` will not be applied. The reason is the use of `Symbol('...')` instead of `Symbol.for('...')` to keep the list of aspects on the construct object. - The first version creates a unique symbol per library, while adding a naming hint. - The second version deduplicates: all symbols with the same naming hint will receive the same symbol. The second version is necessary to make sure that different copies of the `aws-cdk-lib` library store their aspects under the same key. Fixes #18921, #18778, #19390.
When construct libraries are purposely symlinked (as opposed of collectively `npm install`ed), depending on how this is done they may end up with multiple copies of `aws-cdk-lib`. If that happens, Aspects from a different `aws-cdk-lib` copy than the one providing `App` will not be applied. The reason is the use of `Symbol('...')` instead of `Symbol.for('...')` to keep the list of aspects on the construct object. - The first version creates a unique symbol per library, while adding a naming hint. - The second version deduplicates: all symbols with the same naming hint will receive the same symbol. The second version is necessary to make sure that different copies of the `aws-cdk-lib` library store their aspects under the same key. Fixes #18921, #18778, #19390, #18914
This works now for me! |
|
What is the problem?
Aspects doesn't pick up resources that have been symlinked
Reproduction Steps
Follow steps in README here: https://github.com/bestickley/cdk-aspects-error
What did you expect to happen?
Aspects should throw error picking up bucket
What actually happened?
Aspects doesn't throw error picking up bucket.
CDK CLI Version
2.10.0
Framework Version
2.10.0
Node.js Version
16.13.2
OS
macOS
Language
Typescript
Language Version
3.9.7
Other information
No response
The text was updated successfully, but these errors were encountered: