amazon-cloudformation - 在 / 使用 CF 为 API 网关创建方法
问题描述
如何使用 CF 在 API Gateway 的根/文件夹下创建方法?例如,我有一个如下所示的网关:
/ 选项发布
但是,当尝试使用 CF 执行此操作时,我得到:资源的路径部分只允许 a-zA-Z0-9._- 和开头和结尾的花括号。所以我的 PathPart 是有问题的线。
ApiGate:
Type: AWS::ApiGateway::Resource
Properties:
ParentId: !GetAtt
- ApiGateApi
- RootResourceId
PathPart: '{/}'
RestApiId: !Ref ApiGateApi
我可以将 PathPart 更改为其他内容,但随后它将它创建为 / 下的子对象,这是我不想要的。
解决方案
这解决了我的问题,在我的情况下,我需要 2 种方法:1. 将响应对 root 的请求,例如https://<api-url>/prod
或https://<api-url>/prod/
. 这将使用 API Gateway 的 RootResourceId:
ResourceId: !GetAtt myApiGateway.RootResourceId
- 这将响应任何已设置的请求
https://<api-url>/prod/
。可能是petstore
或者如果使用,{proxy+}
那么后端工作负载将尝试解决请求。它将引用模板中定义的资源类型:
ResourceId: !Ref myResource
推荐阅读
- javascript - 在Angular中组合没有重复的数组
- java - 构建主项目时如何自动构建子项目?
- excel - 使用 filedialog 选择并打开工作簿并立即在该新打开的工作簿中运行宏
- java - 警告:JPA 不支持自定义隔离级别,因此启动 Jobs 时可能不会获取锁
- kubernetes - 是否有可能在一个 aws 区域中创建主节点并在另一个区域中创建工作节点?
- javascript - 将 Express 请求传递给 Axios POST 请求
- flutter - 仅将指定的可选参数传递给底层小部件
- java - 使用 java 中的 notesFactory 向 Lotus Notes 中的通用 ID 发送电子邮件
- jakarta-ee - Java Batch 作业:如何等待用户决定?
- javascript - 无法通过 appscript webapp 中的 HTML 表单上传大文件