Skip to content

Commit

Permalink
Replicate jslib-aws v0.48 changes in next docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Dec 12, 2023
1 parent e1c0016 commit a13d3ed
Show file tree
Hide file tree
Showing 36 changed files with 2,094 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: 'EventBridgeClient.putEvents'
title: 'putEvents'
head_title: 'EventBridgeClient.putEvents'
slug: 'eventbridgeclient-putevents'
description: 'EventBridgeClient.putEvents sends custom events to Amazon EventBridge'
excerpt: 'EventBridgeClient.putEvents sends custom events to Amazon EventBridge'
---
Expand All @@ -12,33 +11,32 @@ excerpt: 'EventBridgeClient.putEvents sends custom events to Amazon EventBridge'

### Parameters

| Parameter | Type | Description |
| :------------ | :-------------- | :----------------------------------------------------------------------------------------------------------------------- |
| input | [PutEventsInput](#puteventsinput) | An array of objects representing events to be submitted. |
| Parameter | Type | Description |
| :-------- | :-------------------------------- | :------------------------------------------------------- |
| input | [PutEventsInput](#puteventsinput) | An array of objects representing events to be submitted. |

#### PutEventsInput

| Parameter | Type | Description |
| :-------- | :-------------- | :----------------------------------------------------------------------------------------------------------------------- |
| Entries | [EventBridgeEntry](#eventbridgeentry)[] | An array of objects representing events to be submitted. |
| EndpointId | string (optional) | The ID of the target to receive the event. |
| Parameter | Type | Description |
| :--------- | :-------------------------------------- | :------------------------------------------------------- |
| Entries | [EventBridgeEntry](#eventbridgeentry)[] | An array of objects representing events to be submitted. |
| EndpointId | string (optional) | The ID of the target to receive the event. |

#### EventBridgeEntry

| Parameter | Type | Description |
| :-------- | :----- | :----------------------------------------------------------------------------------------------------------------------- |
| Source | string | The source of the event. |
| Detail | object | A JSON object containing event data. |
| DetailType | string | Free-form string used to decide what fields to expect in the event detail. |
| Resources | string[] (optional) | AWS resources, identified by Amazon Resource Name (ARN), which the event primarily concerns. |
| EventBusName | string (optional) | The event bus that will receive the event. If you omit this, the default event bus is used. Only the AWS account that owns a bus can write to it. |

| Parameter | Type | Description |
| :----------- | :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| Source | string | The source of the event. |
| Detail | object | A JSON object containing event data. |
| DetailType | string | Free-form string used to decide what fields to expect in the event detail. |
| Resources | string[] (optional) | AWS resources, identified by Amazon Resource Name (ARN), which the event primarily concerns. |
| EventBusName | string (optional) | The event bus that will receive the event. If you omit this, the default event bus is used. Only the AWS account that owns a bus can write to it. |

### Returns

| Type | Description |
| :-------------- | :---------------------------------------------------------------------------------- |
| `Promise<void>` | A Promise that fulfills when the events have been sent to Amazon EventBridge. |
| Type | Description |
| :-------------- | :---------------------------------------------------------------------------- |
| `Promise<void>` | A Promise that fulfills when the events have been sent to Amazon EventBridge. |

### Example

Expand All @@ -56,19 +54,19 @@ const awsConfig = new AWSConfig({

const eventBridge = new EventBridgeClient(awsConfig);
const eventEntry = {
Source: "my.source",
Detail: {
key: "value"
},
DetailType: "MyDetailType",
Resources: ["resource-arn"],
Source: 'my.source',
Detail: {
key: 'value',
},
DetailType: 'MyDetailType',
Resources: ['resource-arn'],
};

export default async function () {
await eventBridge.putEvents({
Entries: [eventEntry]
});
await eventBridge.putEvents({
Entries: [eventEntry],
});
}
```

{{< /code >}}
{{< /code >}}
55 changes: 55 additions & 0 deletions docs/sources/next/javascript-api/jslib/aws/KMSClient/KMSDataKey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: 'KMSDataKey'
slug: 'kmsdatakey'
head_title: 'KMSDataKey'
description: 'KMSDataKey is returned by the KMSClient.*DataKey methods that query KMS data keys'
---

# KMSDataKey

`KMSClient.*DataKey` methods, querying Key Management Service data keys, return some KMSDataKey instances.
The KMSDataKey object describes an Amazon Key Management Service data key.
For instance, the [`generateDataKey`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/kmsclient-generatedatakey/) returns the generated KMSDataKey object.

| Name | Type | Description |
| :-------------------------- | :----- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
| `KMSDataKey.id` | string | The identifier of the Key Management Service key that encrypted the data key. |
| `KMSDataKey.ciphertextBlob` | string | The base64-encoded encrypted copy of the data key. |
| `KMSDataKey.plaintext` | string | The plain text data key. Use this data key to encrypt your data outside of Key Management Service. Then, remove it from memory as soon as possible. |

### Example

{{< code >}}

```javascript
import exec from 'k6/execution';

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

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

const kms = new KMSClient(awsConfig);
const testKeyId = 'e67f95-4c047567-4-a0b7-62f7ce8ec8f48';

export default async function () {
// List the KMS keys the AWS authentication configuration
// gives us access to.
const keys = await kms.listKeys();

// If our test key does not exist, abort the execution.
if (keys.filter((b) => b.keyId === testKeyId).length == 0) {
exec.test.abort();
}

// Generate a data key from the KMS key.
const key = await kms.generateDataKey(testKeyId, 32);
}
```

_A k6 script that generating a data key from an AWS Key Management Service key_

{{< /code >}}
49 changes: 49 additions & 0 deletions docs/sources/next/javascript-api/jslib/aws/KMSClient/KMSKey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: 'KMSKey'
head_title: 'KMSKey'
description: 'KMSKey is returned by the KMSClient.* methods that query KMS keys'
excerpt: 'KMSKey is returned by the KMSClient.* methods that query KMS keys'
---

# KMSKey

`KMSClient.*` methods querying Key Management Service keys return some `KMSKey` instances. Namely, `listKeys()` returns an array of `KMSKey` objects. The `KMSKey` object describes an Amazon Key Management Service key.

| Name | Type | Description |
| :-------------- | :----- | :--------------------------- |
| `KMSKey.keyId` | string | Unique identifier of the key |
| `KMSKey.keyArn` | string | ARN of the key |

### Example

{{< code >}}

```javascript
import exec from 'k6/execution';

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

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

const kms = new KMSClient(awsConfig);
const testKeyId = 'e67f95-4c047567-4-a0b7-62f7ce8ec8f48';

export default async function () {
// List the KMS keys the AWS authentication configuration
// gives us access to.
const keys = await kms.listKeys();

// If our test key does not exist, abort the execution.
if (keys.filter((b) => b.keyId === testKeyId).length == 0) {
exec.test.abort();
}
}
```

_A k6 script querying the user's Key Management Service keys and verifying their test key exists_

{{< /code >}}
10 changes: 5 additions & 5 deletions docs/sources/next/javascript-api/jslib/aws/KMSClient/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Both the dedicated `kms.js` jslib bundle and the all-encompassing `aws.js` bundl

### Methods

| Function | Description |
| :-------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- |
| [listKeys](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/00 listkeys) | List the all the Key Management Service keys in the caller's AWS account and region. |
| [generateDataKey](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/00 generateDataKey) | Generate a symmetric data key for use outside of the AWS Key Management Service. |
| Function | Description |
| :------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- |
| [listKeys](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/listkeys) | List the all the Key Management Service keys in the caller's AWS account and region. |
| [generateDataKey](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/generatedatakey) | Generate a symmetric data key for use outside of the AWS Key Management Service. |

### Throws

Expand Down Expand Up @@ -63,7 +63,7 @@ export default async function (data) {

export function handleSummary(data) {
return {
stdout: textSummary(data, { indent: ' ', enableColors: true }),
'stdout': textSummary(data, { indent: ' ', enableColors: true }),
'./test-run.key': data.dataKey,
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: 'generateDataKey'
head_title: 'KMSClient.generateDataKey'
description: 'KMSClient.generateDataKey generates a symmetric data key for use outside of the AWS Key Management Service'
excerpt: 'KMSClient.generateDataKey generates a symmetric data key for use outside of the AWS Key Management Service'
---

# KMSClient.generateDataKey

`KMSClient.generateDataKey` generates a symmetric data key for use outside of the AWS Key Management Service.

### Parameters

| Name | Type | Description |
| :----- | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | string | The identifier of the key. This can be either the key ID or the Amazon Resource Name (ARN) of the key. |
| `size` | number | The length of the data key. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). For 256-bit (32-byte) data keys, use the value 32, instead. |

### Returns

| Type | Description |
| :------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------- |
| Promise<[KMSDataKey](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/kmsdatakey)> | A Promise that fulfills with a [KMSDataKey](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/kmskey) object. |

### Example

{{< code >}}

```javascript
import exec from 'k6/execution';

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

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

const kms = new KMSClient(awsConfig);
const testKeyId = 'e67f95-4c047567-4-a0b7-62f7ce8ec8f48';

export default async function () {
// List the KMS keys the AWS authentication configuration
// gives us access to.
const keys = await kms.listKeys();

// If our test key does not exist, abort the execution.
if (keys.filter((b) => b.keyId === testKeyId).length == 0) {
exec.test.abort();
}

// Generate a data key from the KMS key.
const key = await kms.generateDataKey(testKeyId, 32);
}
```

_A k6 script that generating a data key from an AWS Key Management Service key_

{{< /code >}}
50 changes: 50 additions & 0 deletions docs/sources/next/javascript-api/jslib/aws/KMSClient/listKeys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: 'listKeys'
head_title: 'KMSClient.listKeys()'
description: "KMSClient.listKeys lists all the KMS keys in the caller's AWS account and region"
excerpt: "KMSClient.listKeys lists all the KMS keys in the caller's AWS account and region"
---

# KMSClient.listKeys()

`KMSClient.listKeys()` lists all the Key Management Service keys in the caller's AWS account and region.

### Returns

| Type | Description |
| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------- |
| Promise<[KMSKey[]](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/kmskey)> | A Promise that fulfills with an array of [`KMSKey`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws/kmsclient/kmskey) objects. |

### Example

{{< code >}}

```javascript
import exec from 'k6/execution';

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

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

const kms = new KMSClient(awsConfig);
const testKeyId = 'e67f95-4c047567-4-a0b7-62f7ce8ec8f48';

export default async function () {
// List the KMS keys the AWS authentication configuration
// gives us access to.
const keys = await kms.listKeys();

// If our test key does not exist, abort the execution.
if (keys.filter((b) => b.keyId === testKeyId).length == 0) {
exec.test.abort();
}
}
```

_A k6 script querying the user's Key Management Service keys and verifying their test key exists_

{{< /code >}}
41 changes: 41 additions & 0 deletions docs/sources/next/javascript-api/jslib/aws/S3Client/Bucket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: 'Bucket'
head_title: 'Bucket'
description: 'Bucket is returned by the S3Client.* methods who query S3 buckets.'
---

# Bucket

Bucket is returned by the S3Client.\* methods that query S3 buckets. Namely, `listBuckets()` returns an array of Bucket objects. The Bucket object describes an Amazon S3 bucket.

| Name | Type | Description |
| :-------------------- | :----- | :--------------------------- |
| `Bucket.name` | string | The S3 bucket's name |
| `Bucket.creationDate` | Date | The S3 bucket's creationDate |

### Example

{{< code >}}

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

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

const s3 = new S3Client(awsConfig);

export default async function () {
// List the buckets the AWS authentication configuration
// gives us access to.
const buckets = await s3.listBuckets();
console.log(JSON.stringify(buckets));
}
```

_A k6 script that will query the user's S3 buckets and print all of their metadata_

{{< /code >}}
Loading

0 comments on commit a13d3ed

Please sign in to comment.