问题描述
在我们的无服务器应用程序中,我们已将以下内容添加到 serverless.yml 的资源块中,以便 4xx 和 5xx 错误响应具有 CORS 标头。
GatewayResponseDefault4XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: 'ApiGatewayRestApi'
GatewayResponseDefault5XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: DEFAULT_5XX
RestApiId:
Ref: 'ApiGatewayRestApi'
直到最近这对我们有用,但现在尝试使用 serverless deploy
部署应用程序时会导致以下错误。当我们部署应用并从 serverless.yml
中删除上述资源时,此错误就会消失。
The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayResourceViewer,ApiGatewayRestApi] in the Resources block of the template.
但问题是我们需要这些资源才能成功捕获从应用程序返回的 4xx 和 5xx 错误。我们不能只是删除它们然后继续。
有什么办法可以在保留这些资源的同时,仍无错误地部署我们的应用程序?非常感谢有用的建议。
背景信息
serverless-plugin-split-stacks
配置:
custom:
splitStacks:
perFunction: false
perType: true
perGroupFunction: false
serverless -v
输出:
Framework Core: 2.15.0
Plugin: 4.4.2
SDK: 2.3.2
Components: 3.4.7
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)