通过 CloudFormation 模板指定 $default API 网关阶段?

Specify a $default API Gateway stage via CloudFormation template?

我正在使用 AWS SAM

从文档中,我看到 “舞台名称只能包含字母数字字符、连字符和下划线,或者是 $default。”

但是当我尝试时:

Resources:
  ExpressApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: '$default'

堆栈创建失败并显示消息:

Stage name only allows a-zA-Z0-9_

我只希望能够在路径中不带 StageName 的情况下使用 API 基础 URL。我的API只有一个阶段。

有没有办法在不将自定义域连接到 API 的情况下做到这一点?

对于HTTP API

StageName 是可选的,因为 HTTP API 默认创建 $default 阶段,无需任何前缀和自动部署即可访问。

If no name is specified, AWS SAM uses the $default stage from API Gateway

对于REST API

舞台名称是必需的。 Rest APIs 没有自动部署。 SAM 模板在幕后创建该阶段并将代码部署到该阶段,它只允许 a-zA-Z0-9_