[#181] Support AWS credentials profiles

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
Alexey Vanin 2024-12-28 12:52:27 +03:00
parent 14f26e47dc
commit a326fbcbf8
2 changed files with 5 additions and 2 deletions

View file

@ -107,11 +107,12 @@ const s3_cli = s3.connect("https://s3.frostfs.devenv:8080")
You can also provide additional options: You can also provide additional options:
```js ```js
import s3 from 'k6/x/frostfs/s3'; import s3 from 'k6/x/frostfs/s3';
const s3_cli = s3.connect("https://s3.frostfs.devenv:8080", {'no_verify_ssl': 'true', 'timeout': '60s'}) const s3_cli = s3.connect("https://s3.frostfs.devenv:8080", {'no_verify_ssl': 'true', 'timeout': '60s', 'aws_profile': 'metal'})
``` ```
* `no_verify_ss` - Bool. If `true` - skip verifying the s3 certificate chain and host name (useful if s3 uses self-signed certificates) * `no_verify_ss` - Bool. If `true` - skip verifying the s3 certificate chain and host name (useful if s3 uses self-signed certificates)
* `timeout` - Duration. Set timeout for requests (in http client). If omitted or zero - timeout is infinite. * `timeout` - Duration. Set timeout for requests (in http client). If omitted or zero - timeout is infinite.
* `aws_profile` - String. Use custom profile credentials from `$HOME/.aws/credentials` file. If omitted or empty - use default profile.
### Methods ### Methods
- `createBucket(bucket, params)`. Returns dictionary with `success` boolean flag - `createBucket(bucket, params)`. Returns dictionary with `success` boolean flag

View file

@ -59,7 +59,9 @@ func (s *S3) Connect(endpoint string, params map[string]string) (*Client, error)
}, nil }, nil
}) })
cfg, err := config.LoadDefaultConfig(s.vu.Context(), config.WithEndpointResolverWithOptions(resolver)) cfg, err := config.LoadDefaultConfig(s.vu.Context(),
config.WithEndpointResolverWithOptions(resolver),
config.WithSharedConfigProfile(params["aws_profile"]))
if err != nil { if err != nil {
return nil, fmt.Errorf("configuration error: %w", err) return nil, fmt.Errorf("configuration error: %w", err)
} }