在放大自定义资源中引用CDK的REST API资源
我需要自定义REST API端点的方法处理程序,并将其指向SQS,而不是lambda函数。我正在暂停尝试,以获取对RESTAPI
对象的完整引用...
RESTAPI对象我从RESTAPI.FROMRESTAPIID
不完整。我不能这样做:
const restApi = apigateway.RestApi.fromRestApiId(this, 'RestApi', dependencies.api.rest.ApiId);
const queueResource = restApi.root.resourceForPath('/webhooks');
...没有得到此错误: 错误:使用FrofRestapiid()导入时未配置root。 )API。
使用FrofRestApiatTributes ( 找到对的参考。 restapi.fromrestapiattributes
的文档显示了这一点,但是我没有props
:
const api = RestApi.fromRestApiAttributes(this, 'RestApi', {
restApiId: props.restApiId,
rootResourceId: props.rootResourceId,
});
有人知道如何访问rootresourceid
吗?
I need to customize the method handler for a REST API endpoint and point it to SQS instead of a Lambda function. I'm stalling out trying to get a full reference to the RestApi
object...
The RestApi object I get back from RestApi.fromRestApiId
is incomplete; I can't do this:
const restApi = apigateway.RestApi.fromRestApiId(this, 'RestApi', dependencies.api.rest.ApiId);
const queueResource = restApi.root.resourceForPath('/webhooks');
...without getting this error:Error: root is not configured when imported using fromRestApiId(). Use fromRestApiAttributes() API instead.
I can't use RestApi.fromRestApiAttributes
as that requires the rootResourceId
-- which I can't seem to find a reference to. The documentation for RestApi.fromRestApiAttributes
shows this, but I don't have props
:
const api = RestApi.fromRestApiAttributes(this, 'RestApi', {
restApiId: props.restApiId,
rootResourceId: props.rootResourceId,
});
Does anyone know how to access the rootResourceId
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
root资源(
/
)ID是一个字母数字字符串,例如4cfzeywftb
,可以在控制台面包屑中找到:或通过调用
get-code> get-code> get-resources
:The root resource (
/
) id is a alphanumeric string like4cfzeywftb
, which can be found in the console breadcrumbs:or by calling
get-resources
: