【问题标题】:AWS - Serverless - "message": "Internal server error" when deploying, but work offlineAWS - 无服务器 - “消息”:部署时出现“内部服务器错误”,但脱机工作
【发布时间】:2018-05-17 13:04:51
【问题描述】:

我在使用无服务器框架和 Amazon Web Services(更具体地说是 API Gateway 服务)部署项目时遇到问题。

在我的本地机器上,当我执行serverless offline 时,一切正常: 去http://localhost:3000/时,我有:

{
    "message": "welcome"
}

导航到http://localhost:3000/examples 时,我有:

{
    "message": "Example test"
}

但是,当使用serverless deploy 进行部署时,只有第一个有效。下一个显示如下:

{
    "message": "Internal server error"
}

在我的代码中,我有以下路线:

app.use('/examples', ExampleController)

app.get('/', (request, response) => {
  response.json({
    message: 'welcome'
  })
})

这就是我的 ExampleController 中的内容:

ExampleController.get('/', (request, response) => {
  response.json({
    message: 'Example test'
  })
})

这可能是什么问题?

【问题讨论】:

  • 您能否提供对调试此类问题有很大帮助的 CloudWatch 日志?
  • “只有第一个有效”是什么意思?正如@KaHouIeong 已经提到的,请查看 CloudWatch 日志。
  • 修复了问题,看我的回答。

标签: amazon-web-services express aws-api-gateway serverless-framework


【解决方案1】:

通过在 serverless.yml 的 iamRoleStatements 中添加以下角色解决了我的问题:

-  Effect: "Allow"
   Action:
     - "cloudformation:DescribeStackResource"
   Resource: "*"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-18
    • 2021-10-07
    • 2014-05-28
    • 1970-01-01
    • 2013-03-09
    • 1970-01-01
    • 2018-10-22
    • 2019-01-02
    相关资源
    最近更新 更多