-
Notifications
You must be signed in to change notification settings - Fork 75
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
[BUG] Error: LogicalId defined outside of stack #684
Comments
cc @JeremyJonas , I noticed you've been handling the other bug. |
Hi @kornicameister, could you explain a bit more details about your "custom" stack vs "ordinary stack"? And from your comment the sample code provide works right, as you stated no error with "ordinary stack" and your example is an "ordinary stack" right? Given the Does your custom stack evaluate to true for
Code where error occurs: aws-pdk/packages/cdk-graph/src/core/graph.ts Lines 1170 to 1179 in 43c0d6d
|
@JeremyJonas yes, those tests you asked about, everything seems to be just fine. |
@JeremyJonas as to what this stack of mine really is. It is simply speaking a class that extends from
And that's really all that is. For most of the time my stack does not really create extra resources, just sets values later passed into constructor of Update: I actually made some more tests. Now I noticed that
So we're failing now on the output which makes me think that whatever construct gets created in my stack is something...flawed. I don't know what that can be... maybe something messed up on Update2: I removed the outputs from 1st update and now I get the failure on another resource. Error is exactly the same, just resource ID changes. |
Hi @kornicameister, does Let me know if all these conditions are still true, which means an issue on our end, otherwise means need to provide support for detecting stacks like yours and will need to go a bit deeper into understanding how it is implemented and why it does not get reported as a stack. |
@JeremyJonas I created couple of tests to verify what you wanted: it('should return true if stack is a stack', () => {
expect(cdk.Stack.isStack(stack)).toBe(true);
});
it('should return the same stack from cdk.Stack.of', () => {
expect(cdk.Stack.of(stack)).toBe(stack);
});
it('should return the same stack from cdk.Stack.of with another resource', () => {
const ttl = new TimeToLive(stack, 'TTL', {
ttl: cdk.Duration.hours(1),
});
expect(cdk.Stack.of(ttl)).toBe(stack);
}); here's the result:
|
Hi @kornicameister, was away for a bit sorry for delay. Your test disproves my initial thoughts on this one. Without being able to repro this not sure how to resolve. Any chance you could scrap together an example repro of it? You could also run in inspect mode with breakpoint at the error, maybe can provide more details, which would be my first step if running your repro code. If all else fails, we could try adding a flag to ignore the error. But I am definitely curious to know what is actually causing it. |
I can try, but wonder if that's gonna work out. @JeremyJonas one thing... can a fact that this error occurs when using said stack of mine via NPM package. |
InterestingCould you share a link to your code ? Or at least your .projenrc file ?Please note: My working hours may not be your working hours. Please do not feel obligated to reply outside of your normal work schedule!Sent on the go - please excuse mistakes On 13 Feb 2024, at 11:29 pm, Tomasz Trębski ***@***.***> wrote:
I can try, but wonder if that's gonna work out.
@JeremyJonas one thing... can a fact that this error occurs when using said stack of mine via NPM package.
You see I have a library of re-usable CDK components that I ship via NPM package.
Might be I have something messed up on this end?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
@mteichtahl I am not using projen. My setup is based on top of pure That's my package.json (note: redacted): {
"name": "xxx",
"version": "0.0.0",
"description": "Collection of CDK components",
"license": "UNLICENSED",
"main": "dist/index.js",
"scripts": {
"build": "jsii -vvv --compress-assembly --fix-peer-dependencies",
"postbuild": "npm run docgen",
"build:watch": "jsii -w",
"docgen": "npx rimraf README.md && jsii-docgen -o README.md -r",
"prepackage": "npm run build",
"package": "npx rimraf dist/ && jsii-pacmak -vvv",
"test:unit": "jest",
"test:unit:watch": "jest --watch --watchman"
},
"types": "dist/index.d.ts",
"dependencies": {
"@cloudcomponents/cdk-temp-stack": "^2.1.0"
},
"peerDependencies": {
"aws-cdk-lib": "^2.98",
"constructs": "^10.3.0"
},
"devDependencies": {
"aws-cdk-lib": "2.115.0",
"constructs": "10.3.0",
"jsii": "~5.3.7",
"jsii-diff": "^1.94.0",
"jsii-docgen": "^10.3.7",
"jsii-pacmak": "^1.94.0",
"jsii-reflect": "^1.94.0",
"jsii-rosetta": "~5.3.4"
},
"engines": {
"node": ">=18.16.0"
},
"jsii": {
"outdir": "dist",
"targets": {},
"tsc": {
"outDir": "dist",
"rootDir": "src"
},
"versionFormat": "short"
}
} I do not have any other |
+1, same thing happens simply with EKS L3 construct `import { Stack, StackProps } from "aws-cdk-lib"; export class ApplicationStack extends Stack {
} running 'npm run build' throws
|
Not that I am happy...but I am happy that we have something to reproduce an error. I tried reproducing that but without any luck. |
I have the same situation with EKS higher-level constructs. After some debugging, I found a temp solution (i.e. a hack), don't have a lasting idea yet. And it only seems to be a problem when using PDK along with CDK. Here's the patch that gets things going again - though not great:
|
Reason seems to be: classes having custom fqn are instanceof NestedStack, but the info gets lost here |
btw: it only appears with PDK and automatic diagram generation |
@sebastianrothbucher did you manage to get a fix? need some more info? |
I'm good with the fix above, thx |
I'm facing the same issue, when creating stacks for Service Catalog. It does not matter, if Products are created from asset or from stack. In this case, the error is more meaningful, as you need to use different classes: one for the CloudFormation Stack of the portfolio and child clases for product creation. From the Portfolio Stack, you need to run the follwoing code to add a Bucket product: import aws_cdk as cdk
class S3BucketProduct(servicecatalog.ProductStack):
def __init__(self, scope, id):
super().__init__(scope, id)
s3.Bucket(self, "BucketProduct")
product = servicecatalog.CloudFormationProduct(self, "Product",
product_name="My Product",
owner="Product Owner",
product_versions=[servicecatalog.CloudFormationProductVersion(
product_version_name="v1",
cloud_formation_template=servicecatalog.CloudFormationTemplate.from_product_stack(S3BucketProduct(self, "S3BucketProduct"))
)
]
) Not using the diagram plugin fixes the issue directly. Thanks for this great package! My error: (.venv) XYZ ~/projects/pmi-service-catalog$ cdk synth --context environment=developer
jsii.errors.JavaScriptError:
@jsii/kernel.RuntimeError: Error: LogicalId defined outside of stack: MountPoint - Node:PARAMETER::ServiceCatalogStackmrhtservicecatalogproductec2901525B4MountPoint3F1F2267
at Kernel._Kernel_ensureSync (/tmp/tmpqi6dbgyw/lib/program.js:9510:23)
at Kernel.invoke (/tmp/tmpqi6dbgyw/lib/program.js:8874:102)
at KernelHost.processRequest (/tmp/tmpqi6dbgyw/lib/program.js:10715:36)
at KernelHost.run (/tmp/tmpqi6dbgyw/lib/program.js:10675:22)
at Immediate._onImmediate (/tmp/tmpqi6dbgyw/lib/program.js:10676:46)
at process.processImmediate (node:internal/timers:476:21)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/XYZ /projects/pmi-service-catalog/app.py", line 132, in <module>
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/XYZ /projects/pmi-service-catalog/app.py", line 127, in main
app.synth()
File "/home/XYZ /projects/pmi-service-catalog/.venv/lib/python3.10/site-packages/aws_cdk/__init__.py", line 21371, in synth
return typing.cast(_CloudAssembly_c693643e, jsii.invoke(self, "synth", [options]))
File "/home/XYZ/projects/pmi-service-catalog/.venv/lib/python3.10/site-packages/jsii/_kernel/__init__.py", line 149, in wrapped
return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
File "/home/XYZ /projects/pmi-service-catalog/.venv/lib/python3.10/site-packages/jsii/_kernel/__init__.py", line 399, in invoke
response = self.provider.invoke(
File "/home/XYZ /projects/pmi-service-catalog/.venv/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 380, in invoke
return self._process.send(request, InvokeResponse)
File "/home/XYZ /projects/pmi-service-catalog/.venv/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 342, in send
raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: Error: LogicalId defined outside of stack: MountPoint - Node:PARAMETER::ServiceCatalogStackmrhtservicecatalogproductec2901525B4MountPoint3F1F2267
Subprocess exited with error 1 |
Describe the bug
I have encountered a bug that was also reported here: #271.
When trying to generate a graph for a stack that uses cdk-temp-stack,
cdk synth
fails with error also reported in #271Expected Behavior
Possible to generate a graph.
Current Behavior
Reproduction Steps
Originally I thought the problem comes from using
TimeToLive
from@cloudcomponents/cdk-temp-stack
.However building a short repro with
cdk.Stack
does not reveal the problem.Reason why I'm bringing up
cdk.Stack
is that I have built my custom stack that sets up some defaults likepermissionBoundary
, synethizer andTimeToLive
to match regulations in my company.Error occurs if I add
MyStack
to ancdk.App
but does not for ordinarycdk.Stack
.I cannot share the full code of my stack however it roughly does this:
Error is not throw here though.
I can share a resulting cloudformation template though:
Possible Solution
No response
Additional Information/Context
CDK: 2.121.1
PDK version used
0.22.50
What languages are you seeing this issue on?
Typescript
Environment details (OS name and version, etc.)
MacOS Sierra
The text was updated successfully, but these errors were encountered: