Javascript Library allowing to interact with AWS resources from k6 scripts
APACHE-2.0 License
Bot releases are visible (Hide)
params
argument to the s3.putObject
method, allowing to pass specific request parameters such as contentDisposition
, contentLength
, contentType
or contentMD5
to such requests.Full Changelog: https://github.com/grafana/k6-jslib-aws/compare/v0.10.0...v0.11.0
Published by oleiade about 1 year ago
host
and scheme
properties to cater to S3-Compatible backends by @oleiade in https://github.com/grafana/k6-jslib-aws/pull/61
AWSConfig
from signature bundle by @oleiade in https://github.com/grafana/k6-jslib-aws/pull/58
Full Changelog: https://github.com/grafana/k6-jslib-aws/compare/v0.9.0...v0.10.0
Published by oleiade about 1 year ago
⚠️ Important: This release contains significant changes that might affect your existing workflows. All client methods are now asynchronous, which is a breaking change from earlier versions. ⚠️
The following public methods have become asynchronous in this release:
KinesisClient
KMSClient
S3Client
SecretsManagerClient
SQSClient
SystemsManagerClient
However, the SignatureV4
class and its methods remain synchronous.
In version v0.9.0
, client methods are now async
functions, which means they return a Promise
instead of a data type. For instance, the S3Client.listBuckets
method, previously defined as listBuckets(): Array<S3Bucket>
, is now an async function: async listBuckets(): Promise<Array<S3Bucket>>
.
You can handle the returned Promise
using the await
keyword. This way, your asynchronous code will have a synchronous look and feel. Here's an example:
export default async function () {
// ...
const buckets = await s3.listBuckets()
}
Note: k6's setup, teardown, handleSummary, and default functions can be declared as async functions.
## Full Example
```javascript
import exec from 'k6/execution'
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.9.0/s3.js'
const testFile = open('bonjour.txt', 'r')
const awsConfig = new AWSConfig.fromEnvironment()
const s3 = new S3Client(awsConfig)
const testBucketName = 'test-jslib-aws'
const testFileKey = 'bonjour.txt'
export default async function () {
const buckets = await s3.listBuckets()
if (buckets.filter((b) => b.name === testBucketName).length == 0) {
exec.test.abort()
}
await s3.putObject(testBucketName, testFileKey, testFile)
const objects = await s3.listObjects(testBucketName)
if (objects.filter((o) => o.key === testFileKey).length == 0) {
exec.test.abort()
}
const obj = await s3.getObject(testBucketName, testFileKey)
await s3.deleteObject(testBucketName, testFileKey)
}
If you're using an older version of k6 that doesn't support asynchronous code execution, we recommend staying with v0.8.1 until you upgrade your k6 version.
Published by oleiade about 1 year ago
copyObject
operation, thanks to @bendennis in #53https://github.com/grafana/k6-jslib-aws/compare/v0.8.0...v0.8.1
Published by oleiade over 1 year ago
Full Changelog: https://github.com/grafana/k6-jslib-aws/compare/v0.7.2...v0.8.0
Published by oleiade over 1 year ago
This release offers:
SQSClient
allowing users to interact with the Amazon Simple Queue service from their k6 scripts. Thanks @nickcaballero and @jdinsel-xealth for your contributions 🙇🏻AWSConfig
now has a static fromEnvironment
method, allowing to include the AWS configuration from environment variables in a one-linerconst config = AWSConfig.fromEnvironment()
accessKeyId
configuration. Errors have also been adjusted to be clearer in the event of a misconfiguration.SignatureV4
class, which is also used by most of our client classes would have produced incorrect signatures, depending on the request's payload.Published by immavalls almost 2 years ago
This version contains minor bug fixes:
S3Client.putObject(bucketName, objectKey, data)
not signing the host
header and throwing:
ERRO[0000] S3ServiceError: There were headers present in the request which were not signed
Renamed config's accessKeyID
to accessKeyId
in https://github.com/grafana/k6-jslib-aws/blob/main/src/internal/s3.ts signing credentials.
Published by oleiade almost 2 years ago
This version contains a complete rewrite of the AWS signature v4 procedure, and exposes a SignatureV4
class allowing to both sign
and presign
requests to AWS directly from your k6 scripts 🚀
It is also now possible to override the jslib's client classes (S3Client
, SecretsManagerClient
, etc) host
, in order to, for example, interact with a AWS-compatible backend. We actually use that new feature ourselves in our test suite, in order to interact with localstack.
Published by oleiade about 2 years ago
This version adds support for a limited subset of the Amazon AWS Systems Manager service 🚀
From the ssm.js
file, users are now able to use the SystemsManagerClient
to retrieve a parameter from Amazon Systems Manager, using the getParameter
method.
A big thank you to @mcnamaram for contributing this feature and making this release possible 🎉 👏🏻 🙇🏻
Published by oleiade over 2 years ago
Includes:
Published by oleiade over 2 years ago
The bundling of the library has been reshaped so that it delivers three different JS files, as well as their respective source-maps:
aws.min.js
: includes the whole set of available AWS services.s3.min.js
: includes the S3Client
client, as well as its dependencies.secrets-manager.min.js
: includes the SecretsManagerClient
, as well as its dependencies.The whole codebase has also been ported to typescript, to offer and support type annotations, which both helps to develop the library and using it.
Published by oleiade over 2 years ago
This version contains minor improvements, refactors and bug fixes:
S3Client.listObjects
prefix parameter,S3Object.storageClass
is set when returned by theS3Client.getObject
method.SecretsManagerError
toSecretsManagerServiceError
for consistency.SecretsManagerClient
methods secretID
parameter toid
, and secretString
to secret
.