gpt4 book ai didi

amazon-web-services - 无服务器框架错误 : Single API Gateway Project - RootResourceId attribute of API Gateway RestAPI doesn't exist

转载 作者:行者123 更新时间:2023-12-03 07:39:19 24 4
gpt4 key购买 nike

我在使用无服务器框架通过 CloudFormation 在 AWS 中部署应用程序时遇到问题。

我使用“单一 API 网关项目”策略进行部署。我将后端分为多个服务,每个服务都有其存储库内的目录及其 serverless.yml 文件。

要为每个 API 网关分配一个 API 网关,我首先部署一项根服务,为我创建所述 API 网关,并输出 ApiGatewayRestApiId ApiGatewayRestApiRootResourceId 正如我在同一无服务器框架的以下文档中看到的:

https://www.serverless.com/framework/docs/providers/aws/events/apigateway#easiest-and-cicd-friendly-example-of-using-shared-api-gateway-and-api-resources

创建 API 网关的根服务类似于:

...
resources:
Outputs:
ApiGatewayRestApiId:
Value:
Ref: ApiGatewayRestApi
Export:
Name: ${self:provider.stage}-ApiGatewayRestApiId
ApiGatewayRestApiRootResourceId:
Value:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
Export:
Name: ${self:provider.stage}-ApiGatewayRestApiRootResourceId
...

然后,从其余的微服务中,我通过导入这些值来使用它们,如下所示:

service: name 
custom:
APP_ENV: ${env:SERVERLESS_APP}
providers:
apiGateway:
restApiId: !ImportValue ${env:${self:custom.APP_ENV}_API_STAGE}-ApiGatewayRestApiId
restApiRootResourceId: !ImportValue ${env:${self:custom.APP_ENV}_API_STAGE}-ApiGatewayRestApiRootResourceId
...

直到今天,当我尝试仅部署根服务时,我的部署从未遇到过任何问题。我遇到的错误如下:

发生错误:root-beta - 模板错误:API Gateway RestAPI d8zc1j912b 的 RootResourceId 属性不存在。

我检查了所有地方,但找不到出现此错误的原因。

  • 操作系统:linux
  • 节点版本:13.10.0
  • 框架版本:1.60.0
  • 插件版本:3.8.4
  • SDK 版本:2.3.2
  • 组件核心版本:1.1.2
  • 组件 CLI 版本:1.6.0

最佳答案

根据我刚刚在 Github 上看到的评论,这是由总共包含 200 多个资源的 API 引起的。 CloudFormation(用于部署无服务器资源)最多只能检索 8 个页面(共 25 个资源)来定位根资源 id,因此如果它恰好位于第 9 页以上,则会抛出该错误。

我不太确定这些资源的顺序是什么。在我自己的测试中,有时有效,有时失败。

来自 AWS 的原始文本(复制到此处以防 Github 问题消失):

... CloudFormation is making an API call with action “apiateway:GetResources” in order to get the root resource ID. This corresponds to the following API call [1]. This is a paginated response, meaning that it only returns resources 25 at a time (by default). Furthermore, to prevent throttling and time out issues, this is only checked a maximum of 8 pages deep. This means, that this root resource ID must be in the first 200 responses in order to get the root resource ID. Otherwise, it will fail to get this value.

...

The service team is aware of this issue and are working on a way to fix this. However, there is no ETA for this to be available.

来源:https://github.com/serverless/serverless/issues/9036#issuecomment-1047240189

关于amazon-web-services - 无服务器框架错误 : Single API Gateway Project - RootResourceId attribute of API Gateway RestAPI <id> doesn't exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73776368/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com