k6-jslib-aws
k6-jslib-aws copied to clipboard
Fix endpoint argument in `signature.sign` examples
We recently changed how the library handles endpoints to support third-party S3-compatible providers as per #21, #57, etc.
We have recently noticed that the example didn't reflect the usage of the new endpoint
argument of the signature.sign
, and signature.presign
methods. We should update those, as well as the documentation to reflect it 👍🏻
I'm trying to use these methods and am having difficulty parsing the new endpoint
syntax - any help or intermediate links while you work on the docs would be much appreciated!
Hey @bd-g thanks for pointing that out, we're gonna improve the documentation accordingly 🤝
Although it's not clearly documented, the Endpoint
type is actually exported by the signature
module, thus, in the meantime, something along the lines of the following should allow you to move forward:
import { Endpoint, SignatureV4 } from 'https://jslib.k6.io/aws/0.11.0/signature.js'; // or aws.js
// instantiate a signature object
const signer = new SignatureV4(...)
// and pass the endpoint here
signer.sign({
method: 'POST',
endpoint: new Endpoint('https://s3.us-west-1.amazonaws.com'),
path: '/',
headers: {
host: 's3.us-west-1.amazonaws.com',
})
For more details, here's the Endpoint
type definition: https://github.com/grafana/k6-jslib-aws/blob/main/src/internal/endpoint.ts
Let me know if that unblocked you 🙇🏻
I'll have to go and check, but that is similar to what I tried to do just from reading the code. I was getting errors with the host name being undefined, somehow my endpoint url wasn't being parsed properly so I'll go back and post my exact example.
The documentation will be updated to cater to this change in: https://github.com/grafana/k6-docs/pull/1585