【问题标题】:ElasticsearchClientException: Request failed to execute. Call: Status code 403 from: POST /index/ElasticsearchClientException:请求执行失败。调用:状态码 403 来自:POST /index/
【发布时间】:2020-04-13 23:19:30
【问题描述】:

我在执行在 AWS 上下文中调用公共 ES 的 lambda 时遇到问题。此 lambda 由 HTTP API Gateway 事件执行。一切似乎都表明这是 lambda 试图访问 ES 的权限问题,但我的无服务器配置似乎有效:

service: my-service

provider:
  name: aws
  runtime: dotnetcore2.1
  stage: ${opt:stage, "Development"}
  region: ${opt:region, "us-east-1"}

  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "lambda:invokeFunction"
      Resource: "*"    
    - Effect: "Allow"
      Action:
        - es:ESHttpPost
        - es:ESHttpPut
        - es:ESHTTPGet
      Resource: "arn:aws:es:us-east-1:account:domain/domain-name/*"


  environment:
    ES_ENDPOINT: ${file(appsettings.${self:provider.stage}.json):ES_ENDPOINT}
    STAGE: ${self:provider.stage}
    REGION: ${self:provider.region}

  apiKeys:
    - myservice-api-key 

package:
  individually: true

functions:
  myservice_api:
    handler: com.myservice::com.myservice.LambdaEntryPoint::FunctionHandlerAsync
    package:
      artifact: bin/release/netcoreapp2.1/myservice.zip
    events:
      - http:
          path: /{proxy+}
          method: ANY
          cors: true
          private: true

记录我的错误如下:

Invalid NEST response built from a unsuccessful (403) low level call on POST
OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 403 from: POST /index/_search?typed_keys=true

包版本: 巢 7.4.1

【问题讨论】:

    标签: elasticsearch .net-core aws-lambda nest serverless


    【解决方案1】:

    我终于解决了这个问题。我发现的内部异常是:“The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.”。我通过将 Elasticsearch.Net.Aws 的版本从 6.0.0 更改为 7.0.4 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2017-11-15
      • 2020-10-15
      • 1970-01-01
      • 1970-01-01
      • 2018-07-10
      • 1970-01-01
      • 2021-06-29
      • 2022-10-19
      • 2021-10-01
      相关资源
      最近更新 更多