Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serverless JavaScript sample doesn't work (access denied) #85

Closed
dblock opened this issue Jan 12, 2023 · 3 comments
Closed

Serverless JavaScript sample doesn't work (access denied) #85

dblock opened this issue Jan 12, 2023 · 3 comments

Comments

@dblock
Copy link
Contributor

dblock commented Jan 12, 2023

The JavaScript sample in https://github.com/awsdocs/amazon-opensearch-service-developer-guide/blob/master/doc_source/serverless-clients.md doesn't work for OpenSeearch serverless.

Code: https://github.com/dblock/opensearch-node-client-demo/tree/opensearch-serverless-docs

export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_SESSION_TOKEN=
export AWS_REGION=
export ENDPOINT=
npm install
ts-node src/index.ts 
ResponseError: AccessDenied
    at onBody (/Users/dblock/source/dblock/opensearch-node-client-demo/node_modules/@opensearch-project/opensearch/lib/Transport.js:403:23)
    at IncomingMessage.onEnd (/Users/dblock/source/dblock/opensearch-node-client-demo/node_modules/@opensearch-project/opensearch/lib/Transport.js:318:11)
    at IncomingMessage.emit (node:events:525:35)
    at IncomingMessage.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  meta: {
    body: {
      status: 403,
      'request-id': 'b6a4bd0c-1211-9a14-85fa-5776ef5efe18',
      error: [Object]
    },
    statusCode: 403,
    headers: {
      'x-request-id': 'b6a4bd0c-1211-9a14-85fa-5776ef5efe18',
      'content-type': 'application/json',
      date: 'Thu, 12 Jan 2023 13:23:15 GMT',
      'content-length': '191',
      'x-aoss-response-hint': 'X01:gw-helper-deny',
      server: 'aoss-amazon'
    },
    meta: {
      context: null,
      request: [Object],
      name: 'opensearch-js',
      connection: [Object],
      attempts: 0,
      aborted: false
    }
  }
}

The sample signs the body and forces a content-length of 0, as per the documentation. That broke at some point since preview. Removing the content body and not signing a content-length header works around it, see https://github.com/dblock/opensearch-node-client-demo/blob/opensearch-serverless-aws-sdk2/src/index.ts.

@lizsnyder
Copy link
Member

Hi @dblock as discussed internally, this is a service-side issue. Did you want to keep this open for tracking purposes while we wait for the team to fix it?

@dblock
Copy link
Contributor Author

dblock commented Jan 12, 2023

Hi @dblock as discussed internally, this is a service-side issue. Did you want to keep this open for tracking purposes while we wait for the team to fix it?

Yes.

@lizsnyder
Copy link
Member

Fixed in #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants