grafana / k6-jslib-aws

Javascript Library allowing to interact with AWS resources from k6 scripts
Apache License 2.0
18 stars 29 forks source link

Use path-style URL for AWS Config #26

Closed vuongphamaioz closed 1 year ago

vuongphamaioz commented 1 year ago

Hi,

I'm trying to use this library to connect to my self-hosted MinIO Object Storage that has S3-compatible. I connected to my server successfully. But my server uses path-style URL so I can't get buckets on my server. I haven't found any way to config this. Is there any way to do this? For example, in AWS S3 Javascript SDK, this field is named forcePathStyle.

Thanks.

oleiade commented 1 year ago

Hi @vuongphamaioz πŸ‘‹πŸ» I'm not sure I understand what you meant by "path-style URL"? Could you please expand on this?πŸ™πŸ»

For instance, it would be super helpful if you could provide examples of the requests you're trying to perform that wouldn't work with the latest version of the project.

vuongphamaioz commented 1 year ago

Hi @oleiade,

This is the reference link: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html

The S3 provides 2 types of URL addresses that we send request to, for example:

The default of AWS S3 SDK now is virtual-hosted-style. Below is the example code when I use AWS S3 Javascript SDK.

const s3Client = new S3Client({
  region: "us-east-1",
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  },
  endpoint: {
    url: "https://minio-example.com",
  },
  forcePathStyle: true,
});

Below is the code that I am trying to do

const awsConfig = new AWSConfig({
  region: __ENV.AWS_REGION,
  accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
  secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
  scheme: 'https',
  endpoint: "https://minio-example.com",
  forcePathStyle: true, // has not this field yet
});

Hope it help.

oleiade commented 1 year ago

II see; thanks a lot for the specific example. It does sound like a useful feature to add, indeed, but we would need to do a bit of research to decide on which design would be the bestπŸ‘πŸ» We'll look into it πŸ™‡πŸ»

vuongphamaioz commented 1 year ago

Thank you very much πŸ™πŸ»

ismaelpuerto commented 1 year ago

related https://github.com/grafana/k6-jslib-aws/pull/21

oleiade commented 1 year ago

I believe this might be fixed by #44, which will be released with version 0.8.0, but you can already pick up the specific build files you're interested in from the main branch and take it out for a spin.

Closing. Feel free to reopen if you still experience issues πŸ‘πŸ»