在 cdk 堆栈中访问另一个堆栈中的 AWS 网关资源

Accessing the AWS gateway resource in another stack in cdk stack

我有一个堆栈,其中创建了 api 网关资源。我在这个堆栈下有一个构造,我需要从那里为上述资源创建一个方法。我尝试将资源作为道具传递给构造。但它会抛出错误

throw new Error(${construct.constructor?.name ?? 'Construct'} at '${Node.of(construct).path}' should be created in the scope of a Stack, but no Stack found);

关于在堆栈中创建和传递 aws api 网关资源并将其传递到构造或另一个堆栈的任何想法。

问题在于用于创建构造的范围。将构造的范围更改为 this 然后它工作正常。