You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Serverless Framework部署根服务报错:API Gateway的RootResourceId属性不存在

通过Serverless Framework部署单API网关时出现RootResourceId不存在错误

我采用「Single API Gateway Project」部署策略,后端拆分为多个服务,每个服务在仓库中有独立目录及serverless.yml文件。为实现单API网关共享,先部署根服务创建API Gateway,并按照Serverless Framework文档输出ApiGatewayRestApiId和ApiGatewayRestApiRootResourceId。

根服务配置

...
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
...

此前部署均正常,但今日单独部署根服务时出现错误:

An error occurred: root-beta - Template error: RootResourceId attribute of API Gateway RestAPI d8zc1j912b doesn't exist.

环境信息

  • 操作系统:linux
  • Node版本:13.10.0
  • Framework版本:1.60.0
  • Plugin版本:3.8.4
  • SDK版本:2.3.2
  • Components Core版本:1.1.2
  • Components CLI版本:1.6.0

内容的提问来源于stack exchange,提问作者Nicolas Goldman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 21:55:22