使用ApiGateway {消息:'内部服务器错误'}

时间:2020-06-09 22:50:40

标签: node.js amazon-web-services amazon-cloudformation aws-api-gateway aws-appsync

我在NodeJS上运行的Appsync和ApiGateway遇到问题。我设置了一些资源,这些资源通过与rest api的passThrough定义了多个端点。我也有Stage,它定义了资源路径并启用了缓存。例如,我有一个资源,其路径与以下阶段MethodSetting

相匹配
-   ResourcePath: "/~1v1~1item~1{seasonCode}~1{itemCode}"
    HttpMethod: "GET"
    CacheDataEncrypted: false
    CacheTtlInSeconds: ${self:provider.environment.ITEM_CACHE_TTL}
    CachingEnabled: true
    MetricsEnabled: true

据我所知,ResourcePath必须匹配为此ApiGateway部署定义的资源中的路径。然后,我向在此阶段部署的api上的缓存/直通端点发出get请求,如下所示:

request = {
      hostname: host,
      path: `${pathPrefix}/v1.1/items/${seasonCode}/${itemCode}?policyCode=${
        apiContext.policyCode
      }`,
      headers: apiGatewayHeaders(apiContext)
};

所有阶段MethodSetting都返回以下错误:{ message: 'Internal server error' }来自get请求。我的理解是Appsync会为特定的graphql请求触发一个lambda,而该lambda执行get方法。当lambda用cachign端点调用get方法时,出现上述错误。我正在使用cloudformation进行部署。

编辑:

ApiGateway在CloudWatch中给了我以下日志。

{
    "requestId": "57526082-dc90-4d51-867f-7cee467deacf",
    "ip": "52.34.128.195",
    "caller": "-",
    "requestTime": "1591741653774",
    "httpMethod": "GET",
    "resourcePath": "/v1.1/items/{seasonCode}/{itemCode}",
    "status": "500",
    "protocol": "HTTP/1.1",
    "responseLength": "36"
}

0 个答案:

没有答案