需要配置无服务器资源输出以获取api网关api id

Pet*_*eld 6 aws-cloudformation aws-api-gateway serverless-framework

我有一个无服务器项目,正在创建API网关API等.项目中的一个功能需要为API端点生成URL.

我的计划是使用serverless.yml中的资源输出获取API ID,然后创建URL并将其作为env参数传递给lambda函数.

我的问题/问题是如何将API ID作为serverless.yml中的云形成输出?

我试过了:

resources:
  Outputs:
    RESTApiId:
      Description: The id of the API created in the API gateway
      Value:
        Ref: name-of-api
Run Code Online (Sandbox Code Playgroud)

但这会给出错误:

The CloudFormation template is invalid: Unresolved resource dependencies [name-of-api] in the Outputs block of the template
Run Code Online (Sandbox Code Playgroud)

jen*_*ter 1

无服务器框架有一个文档页面,介绍如何生成资源名称。

看。AWS CloudFormation 资源参考

所以生成的RestAPI资源被称为ApiGatewayRestApi.