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

Document jslib-aws v0.12.1 #1585

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sources/next/examples/http-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Here's an example script to demonstrate how to sign a request to fetch an object

```javascript
import http from 'k6/http';
import { AWSConfig, SignatureV4 } from 'https://jslib.k6.io/aws/0.11.0/signature.js';
import { AWSConfig, SignatureV4 } from 'https://jslib.k6.io/aws/0.12.1/signature.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ EventBridgeClient methods will throw errors in case of failure.
{{< code >}}

```javascript
import { AWSConfig, EventBridgeClient } from 'https://jslib.k6.io/aws/0.11.0/event-bridge.js';
import { AWSConfig, EventBridgeClient } from 'https://jslib.k6.io/aws/0.12.1/event-bridge.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ weight: 10
{{< code >}}

```javascript
import { AWSConfig, EventBridgeClient } from 'https://jslib.k6.io/aws/0.11.0/event-bridge.js';
import { AWSConfig, EventBridgeClient } from 'https://jslib.k6.io/aws/0.12.1/event-bridge.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For instance, the [`generateDataKey`](https://grafana.com/docs/k6/<K6_VERSION>/j
```javascript
import exec from 'k6/execution';

import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.11.0/kms.js';
import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.12.1/kms.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ weight: 20
```javascript
import exec from 'k6/execution';

import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.11.0/kms.js';
import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.12.1/kms.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Both the dedicated `kms.js` jslib bundle and the all-encompassing `aws.js` bundl
```javascript
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js';

import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.11.0/kms.js';
import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.12.1/kms.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.11.0/kms.js';
import { AWSConfig, KMSClient } from 'https://jslib.k6.io/aws/0.12.1/kms.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: 'LambdaClient'
head_title: 'LambdaClient'
description: 'LambdaClient allows interacting with the AWS Lambda service'
weight: 00
---

# LambdaClient

{{< docs/shared source="k6" lookup="blocking-aws-blockquote.md" version="<K6_VERSION>" >}}

`LambdaClient` interacts with [AWS Lambda](https://aws.amazon.com/lambda/). With it, you can invoke a Lambda function.

Both the dedicated `lambda.js` jslib bundle and the all-encompassing `aws.js` bundle include the `LambdaClient`.

### Methods

| Function | Description |
| :------------------------------------------------------------------------------------------------------------------------ | :------------------------------ |
| [invoke(name, payload, [options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/lambdaclient/invoke) | Invokes an AWS Lambda function. |

### Throws

`LambdaClient` methods will throw errors in case of failure.

| Error | Condition |
| :-------------------- | :---------------------------------------------------------- |
| InvalidSignatureError | When invalid credentials were provided. |
| LambdaInvocationError | When AWS replied to the requested invocation with an error. |

### Examples

{{< code >}}

```javascript
import { AWSConfig, LambdaClient } from 'https://jslib.k6.io/aws/0.12.1/lambda.js';
import { check } from 'k6';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
sessionToken: __ENV.AWS_SESSION_TOKEN,
});

const lambdaClient = new LambdaClient(awsConfig);

export default async function () {
const response = await lambdaClient.invoke('add-numbers', JSON.stringify({ x: 1, y: 2 }));

check(response, {
'status is 200': (r) => r.statusCode === 200,
'payload is 3': (r) => r.payload === 3,
});
}
```

{{< /code >}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: 'invoke'
head_title: 'LambdaClient.invoke(name, payload, [options])'
description: 'LambdaClient.invoke invokes an AWS Lamba function'
weight: 10
---

# LambdaClient.invoke(name, payload, [options])

`LambdaClient.invoke` invokes an AWS Lambda function.

### Parameters

| Parameter | Type | Description |
| :-------- | :-------------------------------------- | :---------------------------------------------- |
| name | string | Name of the function to invoke. |
| payload | string | Payload to send to the function being invoked. |
| options | [InvocationOptions](#invocationoptions) | Additional options to customize the invocation. |

#### InvocationOptions

InvocationOptions is an object used to customize the invocation of a Lambda function.
It has the following properties:

| Property | Type | Description |
| :------------- | :---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| invocationType | string (optional) | Specifies the invocation type (synchronous or asynchronous). Possible values are: `RequestResponse`, which invokes the function synchronously, `Event`, which invokes the function asynchronously, and `DryRun` which validates the parameter values and verifies that the user or role has permission to invoke the function. Default is `RequestResponse`. |
| logType | string (optional) | Specifies the type of log to include in the response. Set to `Tail` to include the execution log in the response. Applies to synchronously invoked functions only. Default is `None`. |
| clientContext | string (optional) | Client context to pass to the function. Can be made up of up to 3,583 bytes of base64-encoded data. Default is `null`. |
| qualifier | string (optional) | Version or alias of the function to invoke. |

### Returns

| Type | Description |
| :------------------------------------------------- | :---------------------------------------------------------------- |
| Promise<[InvocationResponse](#invocationresponse)> | A promise that fulfills when the object has been deleted from S3. |

#### InvocationResponse

InvocationResponse is an object that represents the response of an invocation. It has the following properties:

| Property | Type | Description |
| :-------------- | :---------------- | :----------------------------------------- |
| statusCode | number | Status code of the invocation. |
| executedVersion | string (optional) | The version of the function that executed. |
| logResult | string (optional) | Log result of the invocation. |
| payload | string (optional) | Payload returned by the function. |

### Example

{{< code >}}

```javascript
import { AWSConfig, LambdaClient } from 'https://jslib.k6.io/aws/0.12.1/lambda.js';
import { check } from 'k6';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
sessionToken: __ENV.AWS_SESSION_TOKEN,
});

const lambdaClient = new LambdaClient(awsConfig);

export default async function () {
const response = await lambdaClient.invoke('add-numbers', JSON.stringify({ x: 1, y: 2 }));

check(response, {
'status is 200': (r) => r.statusCode === 200,
'payload is 3': (r) => r.payload === 3,
});
}
```

{{< /code >}}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Bucket is returned by the S3Client.\* methods that query S3 buckets. Namely, `li
{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
// listBuckets,
AWSConfig,
S3Client,
} from 'https://jslib.k6.io/aws/0.11.0/s3.js';
} from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ S3MultipartUpload is returned by the [`createMultipartUpload(bucketName, objectK
{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ S3Part is returned by the [`uploadPart(bucketName, objectKey, uploadId, partNumb
import crypto from 'k6/crypto';
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { check } from 'k6';
import exec from 'k6/execution';
import http from 'k6/http';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down Expand Up @@ -111,7 +111,7 @@ export async function handleSummary(data) {
import crypto from 'k6/crypto';
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ weight: 10
{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ weight: 10
import crypto from 'k6/crypto';
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ weight: 10
{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ weight: 10
{{< code >}}

```javascript
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ weight: 10
import crypto from 'k6/crypto';
import exec from 'k6/execution';

import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.11.0/s3.js';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.12.1/s3.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ With it, the user can send messages to specified queues and list available queue
```javascript
import exec from 'k6/execution';

import { AWSConfig, SQSClient } from 'https://jslib.k6.io/aws/0.11.0/sqs.js';
import { AWSConfig, SQSClient } from 'https://jslib.k6.io/aws/0.12.1/sqs.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, SQSClient } from 'https://jslib.k6.io/aws/0.11.0/sqs.js';
import { AWSConfig, SQSClient } from 'https://jslib.k6.io/aws/0.12.1/sqs.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ weight: 10
```javascript
import exec from 'k6/execution';

import { AWSConfig, SQSClient } from 'https://jslib.k6.io/aws/0.11.0/sqs.js';
import { AWSConfig, SQSClient } from 'https://jslib.k6.io/aws/0.12.1/sqs.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Secret is returned by the SecretsManagerClient.\* methods that query secrets. Na
```javascript
import exec from 'k6/execution';

import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.11.0/secrets-manager.js';
import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.12.1/secrets-manager.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ S3 Client methods will throw errors in case of failure.
```javascript
import exec from 'k6/execution';

import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.11.0/secrets-manager.js';
import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.12.1/secrets-manager.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ weight: 10
{{< code >}}

```javascript
import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.11.0/secrets-manager.js';
import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.12.1/secrets-manager.js';

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Loading
Loading