<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>aws on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/</link><description>Recent content in aws on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/javascript-api/jslib/aws/index.xml" rel="self" type="application/rss+xml"/><item><title>AWSConfig</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/awsconfig/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/awsconfig/</guid><content><![CDATA[&lt;h1 id=&#34;awsconfig&#34;&gt;AWSConfig&lt;/h1&gt;
&lt;p&gt;AWSConfig is used to configure an AWS service client instance, such as 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/&#34;&gt;S3Client&lt;/a&gt; or 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/&#34;&gt;SecretsManagerClient&lt;/a&gt;. It effectively allows the user to select a &lt;a href=&#34;https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;region&lt;/a&gt; they wish to interact with, and the AWS credentials they wish to use to authenticate.&lt;/p&gt;
&lt;p&gt;AWSConfig is included in the &lt;code&gt;aws.js&lt;/code&gt; bundle, which includes all the content of the library. It is also included in the various services clients dedicated bundles such as &lt;code&gt;s3.js&lt;/code&gt; and &lt;code&gt;secrets-manager.js&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It takes an options object as its single parameter, with the following properties:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Property&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;region&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;the AWS region to connect to. As described by &lt;a href=&#34;https://docs.aws.amazon.com/general/latest/gr/rande.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Amazon AWS docs&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;accessKeyID&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The AWS access key ID credential to use for authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;secretAccessKey&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The AWS secret access credential to use for authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;sessionToken (optional)&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The AWS secret access token to use for authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;endpoint (optional)&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The AWS endpoint. Useful for local testing.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Name&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;fromEnvironment()&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Creates an &lt;code&gt;AWSConfig&lt;/code&gt; using the &lt;code&gt;AWS_REGION&lt;/code&gt;, &lt;code&gt;AWS_ACCESS_KEY_ID&lt;/code&gt;, &lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt; and &lt;code&gt;AWS_SESSION_TOKEN&lt;/code&gt; environment variables.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;S3 Client methods will throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidArgumentException&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when an invalid region name or credentials were used.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;p&gt;An example showing how you can use k6 to instantiate an &lt;code&gt;AWSConfig&lt;/code&gt; object and use it to configure a &lt;code&gt;SecretsManagerClient&lt;/code&gt; instance.&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import exec from &amp;#39;k6/execution&amp;#39;;

// Note that you AWSConfig is also included in the dedicated service
// client bundles such as `s3.js` and `secrets-manager.js`
import {
  AWSConfig,
  SecretsManagerClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/aws.js&amp;#39;;

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

const secretsManager = new SecretsManagerClient(awsConfig);

export default function () {
  // ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="awsconfig">AWSConfig&lt;/h1>
&lt;p>AWSConfig is used to configure an AWS service client instance, such as
&lt;a href="/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/">S3Client&lt;/a> or
&lt;a href="/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/">SecretsManagerClient&lt;/a>. It effectively allows the user to select a &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html" target="_blank" rel="noopener noreferrer">region&lt;/a> they wish to interact with, and the AWS credentials they wish to use to authenticate.&lt;/p></description></item><item><title>EventBridgeClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/eventbridgeclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/eventbridgeclient/</guid><content><![CDATA[&lt;h1 id=&#34;eventbridgeclient&#34;&gt;EventBridgeClient&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;EventBridgeClient&lt;/code&gt; interacts with the AWS EventBridge service.&lt;/p&gt;
&lt;p&gt;With it, you can send custom events to Amazon EventBridge. These events can then be matched to rules defined in EventBridge. For a full list of supported operations, see &lt;a href=&#34;#methods&#34;&gt;Methods&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both the dedicated &lt;code&gt;event-bridge.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; bundle include the &lt;code&gt;EventBridgeClient&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/eventbridgeclient/putevents/&#34;&gt;putEvents(input)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Send custom events to Amazon EventBridge.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;EventBridgeClient methods will throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidSignatureError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when invalid credentials were provided or the request signature is invalid.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;EventBridgeServiceError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when AWS replied to the requested operation with an error.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import {
  AWSConfig,
  EventBridgeClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/event-bridge.js&amp;#39;;

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 eventBridge = new EventBridgeClient(awsConfig);

export default async function () {
  const eventDetails = {
    Source: &amp;#39;my.custom.source&amp;#39;,
    Detail: { key1: &amp;#39;value1&amp;#39;, key2: &amp;#39;value2&amp;#39; },
    DetailType: &amp;#39;MyDetailType&amp;#39;,
    Resources: [&amp;#39;arn:aws:resource1&amp;#39;],
  };

  const input = {
    Entries: [eventDetails],
  };

  try {
    await eventBridge.putEvents(input);
  } catch (error) {
    console.error(`Failed to put events: ${error.message}`);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="eventbridgeclient">EventBridgeClient&lt;/h1>
&lt;p>&lt;code>EventBridgeClient&lt;/code> interacts with the AWS EventBridge service.&lt;/p>
&lt;p>With it, you can send custom events to Amazon EventBridge. These events can then be matched to rules defined in EventBridge. For a full list of supported operations, see &lt;a href="#methods">Methods&lt;/a>.&lt;/p></description></item><item><title>KinesisClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/</guid><content><![CDATA[&lt;h1 id=&#34;kinesisclient&#34;&gt;KinesisClient&lt;/h1&gt;


&lt;div data-shared=&#34;blocking-aws-blockquote.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;In some cases, using this library&#39;s operations might impact performance and skew your test results.
&lt;br&gt;
&lt;br&gt;
To ensure accurate results, consider executing these operations in the &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;teardown&lt;/code&gt; 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;lifecycle functions&lt;/a&gt;. These functions run before and after the test run and have no impact on the test results.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;&lt;code&gt;KinesisClient&lt;/code&gt; interacts with the AWS Kinesis service.&lt;/p&gt;
&lt;p&gt;With it, you can perform operations such as creating streams, putting records, listing streams, and reading records from streams. For a full list of supported operations, see &lt;a href=&#34;#methods&#34;&gt;Methods&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both the dedicated &lt;code&gt;kinesis.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; bundle include the &lt;code&gt;KinesisClient&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/createstream/&#34;&gt;createStream(streamName, [options])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Create a new Kinesis stream&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/deletestream/&#34;&gt;deleteStream(streamName)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Delete a Kinesis stream&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/liststreams/&#34;&gt;listStreams([options])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;List available Kinesis streams&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/putrecords/&#34;&gt;putRecords(streamName, records)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Put multiple records into a Kinesis stream&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/getrecords/&#34;&gt;getRecords(shardIterator, [options])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Get records from a Kinesis stream shard&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/listshards/&#34;&gt;listShards(streamName, [options])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;List shards in a Kinesis stream&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kinesisclient/getsharditerator/&#34;&gt;getShardIterator(streamName, shardId, shardIteratorType, [options])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Get a shard iterator for reading records from a stream&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;KinesisClient methods will throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidSignatureError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;When invalid credentials are provided.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;KinesisServiceError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;When AWS replies to the requested operation with an error.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { check } from &amp;#39;k6&amp;#39;;
import exec from &amp;#39;k6/execution&amp;#39;;

import {
  AWSConfig,
  KinesisClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/kinesis.js&amp;#39;;

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

const kinesis = new KinesisClient(awsConfig);
const testStreamName = &amp;#39;test-stream&amp;#39;;

export default async function () {
  // List available streams
  const streams = await kinesis.listStreams();
  console.log(&amp;#39;Available streams:&amp;#39;, streams.streamNames);

  // Check if our test stream exists
  if (!streams.streamNames.includes(testStreamName)) {
    // Create the stream if it doesn&amp;#39;t exist
    await kinesis.createStream(testStreamName, { shardCount: 1 });
    console.log(`Created stream: ${testStreamName}`);
  }

  // Put some records into the stream
  const records = [
    {
      data: JSON.stringify({ message: &amp;#39;Hello from k6!&amp;#39;, timestamp: Date.now() }),
      partitionKey: &amp;#39;test-partition-1&amp;#39;,
    },
    {
      data: JSON.stringify({ message: &amp;#39;Another message&amp;#39;, timestamp: Date.now() }),
      partitionKey: &amp;#39;test-partition-2&amp;#39;,
    },
  ];

  const putResult = await kinesis.putRecords(testStreamName, records);
  console.log(&amp;#39;Put records result:&amp;#39;, putResult);

  // List shards in the stream
  const shards = await kinesis.listShards(testStreamName);
  console.log(&amp;#39;Stream shards:&amp;#39;, shards.shards);

  // Get a shard iterator for reading records
  if (shards.shards.length &amp;gt; 0) {
    const shardId = shards.shards[0].shardId;
    const shardIterator = await kinesis.getShardIterator(testStreamName, shardId, &amp;#39;TRIM_HORIZON&amp;#39;);

    // Get records from the shard
    const getResult = await kinesis.getRecords(shardIterator.shardIterator);
    console.log(&amp;#39;Retrieved records:&amp;#39;, getResult.records);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;stream-management&#34;&gt;Stream management&lt;/h4&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import {
  AWSConfig,
  KinesisClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/kinesis.js&amp;#39;;

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

const kinesis = new KinesisClient(awsConfig);

export default async function () {
  const streamName = &amp;#39;my-test-stream&amp;#39;;

  // Create a stream with on-demand billing
  await kinesis.createStream(streamName, {
    streamModeDetails: {
      streamMode: &amp;#39;ON_DEMAND&amp;#39;,
    },
  });

  // List all streams
  const streams = await kinesis.listStreams();
  console.log(&amp;#39;All streams:&amp;#39;, streams.streamNames);

  // Clean up - delete the stream
  await kinesis.deleteStream(streamName);
  console.log(`Deleted stream: ${streamName}`);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="kinesisclient">KinesisClient&lt;/h1>
&lt;div data-shared="blocking-aws-blockquote.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>In some cases, using this library's operations might impact performance and skew your test results.
&lt;br>
&lt;br>
To ensure accurate results, consider executing these operations in the &lt;code>setup&lt;/code> and &lt;code>teardown&lt;/code>
&lt;a href="/docs/k6/v2.3.x/using-k6/test-lifecycle/">lifecycle functions&lt;/a>. These functions run before and after the test run and have no impact on the test results.&lt;/p></description></item><item><title>KMSClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/kmsclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/kmsclient/</guid><content><![CDATA[&lt;h1 id=&#34;kmsclient&#34;&gt;KMSClient&lt;/h1&gt;


&lt;div data-shared=&#34;blocking-aws-blockquote.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;In some cases, using this library&#39;s operations might impact performance and skew your test results.
&lt;br&gt;
&lt;br&gt;
To ensure accurate results, consider executing these operations in the &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;teardown&lt;/code&gt; 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;lifecycle functions&lt;/a&gt;. These functions run before and after the test run and have no impact on the test results.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;&lt;code&gt;KMSClient&lt;/code&gt; interacts with the AWS Key Management Service.&lt;/p&gt;
&lt;p&gt;With it, the user can list all the Key Management Service keys in the caller&amp;rsquo;s AWS account and region. They can also generate symmetric data keys to use outside of AWS Key Management Service.&lt;/p&gt;
&lt;p&gt;Both the dedicated &lt;code&gt;kms.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; bundle include the &lt;code&gt;KMSClient&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kmsclient/listkeys/&#34;&gt;listKeys&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;List the all the Key Management Service keys in the caller&amp;rsquo;s AWS account and region.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/kmsclient/generatedatakey/&#34;&gt;generateDataKey&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Generate a symmetric data key for use outside of the AWS Key Management Service.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;KMSClient&lt;/code&gt; methods throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;InvalidSignatureError&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when using invalid credentials&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;KMSServiceError&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when AWS replied to the requested operation with an error&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { textSummary } from &amp;#39;https://jslib.k6.io/k6-summary/0.0.2/index.js&amp;#39;;

import {
  AWSConfig,
  KMSClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/kms.js&amp;#39;;

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 keyAlias = &amp;#39;alias/k6-key&amp;#39;;

export async function setup() {
  // Create a symmetric data key
  return {
    dataKey: await kms.generateDataKey(keyAlias, 32),
  };
}

export default async function (data) {
  // Use the data key to encrypt data
}

export function handleSummary(data) {
  return {
    &amp;#39;stdout&amp;#39;: textSummary(data, { indent: &amp;#39; &amp;#39;, enableColors: true }),
    &amp;#39;./test-run.key&amp;#39;: data.dataKey,
  };
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="kmsclient">KMSClient&lt;/h1>
&lt;div data-shared="blocking-aws-blockquote.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>In some cases, using this library's operations might impact performance and skew your test results.
&lt;br>
&lt;br>
To ensure accurate results, consider executing these operations in the &lt;code>setup&lt;/code> and &lt;code>teardown&lt;/code>
&lt;a href="/docs/k6/v2.3.x/using-k6/test-lifecycle/">lifecycle functions&lt;/a>. These functions run before and after the test run and have no impact on the test results.&lt;/p></description></item><item><title>LambdaClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/lambdaclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/lambdaclient/</guid><content><![CDATA[&lt;h1 id=&#34;lambdaclient&#34;&gt;LambdaClient&lt;/h1&gt;


&lt;div data-shared=&#34;blocking-aws-blockquote.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;In some cases, using this library&#39;s operations might impact performance and skew your test results.
&lt;br&gt;
&lt;br&gt;
To ensure accurate results, consider executing these operations in the &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;teardown&lt;/code&gt; 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;lifecycle functions&lt;/a&gt;. These functions run before and after the test run and have no impact on the test results.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;&lt;code&gt;LambdaClient&lt;/code&gt; interacts with &lt;a href=&#34;https://aws.amazon.com/lambda/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS Lambda&lt;/a&gt;. With it, you can invoke a Lambda function.&lt;/p&gt;
&lt;p&gt;Both the dedicated &lt;code&gt;lambda.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; bundle include the &lt;code&gt;LambdaClient&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/lambdaclient/invoke/&#34;&gt;invoke(name, payload, [options])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Invokes an AWS Lambda function.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;LambdaClient&lt;/code&gt; methods will throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidSignatureError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;When invalid credentials were provided.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;LambdaInvocationError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;When AWS replied to the requested invocation with an error.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import {
  AWSConfig,
  LambdaClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/lambda.js&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

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(&amp;#39;add-numbers&amp;#39;, JSON.stringify({ x: 1, y: 2 }));

  check(response, {
    &amp;#39;status is 200&amp;#39;: (r) =&amp;gt; r.statusCode === 200,
    &amp;#39;payload is 3&amp;#39;: (r) =&amp;gt; r.payload === 3,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="lambdaclient">LambdaClient&lt;/h1>
&lt;div data-shared="blocking-aws-blockquote.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>In some cases, using this library's operations might impact performance and skew your test results.
&lt;br>
&lt;br>
To ensure accurate results, consider executing these operations in the &lt;code>setup&lt;/code> and &lt;code>teardown&lt;/code>
&lt;a href="/docs/k6/v2.3.x/using-k6/test-lifecycle/">lifecycle functions&lt;/a>. These functions run before and after the test run and have no impact on the test results.&lt;/p></description></item><item><title>S3Client</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/</guid><content><![CDATA[&lt;h1 id=&#34;s3client&#34;&gt;S3Client&lt;/h1&gt;


&lt;div data-shared=&#34;blocking-aws-blockquote.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;In some cases, using this library&#39;s operations might impact performance and skew your test results.
&lt;br&gt;
&lt;br&gt;
To ensure accurate results, consider executing these operations in the &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;teardown&lt;/code&gt; 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;lifecycle functions&lt;/a&gt;. These functions run before and after the test run and have no impact on the test results.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;&lt;code&gt;S3Client&lt;/code&gt; interacts with the AWS Simple Storage Service (S3).&lt;/p&gt;
&lt;p&gt;With it, you can do several operations such as list buckets, list objects in a bucket, or download objects from a bucket. For a full list of supported operations, see &lt;a href=&#34;#methods&#34;&gt;Methods&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Both the dedicated &lt;code&gt;s3.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; bundle include the &lt;code&gt;S3Client&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/listbuckets/&#34;&gt;listBuckets()&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;List the buckets the authenticated user has access to&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/listobjects/&#34;&gt;listObjects(bucketName, [prefix])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;List the objects contained in a bucket&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/getobject/&#34;&gt;getObject(bucketName, objectKey)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Download an object from a bucket&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/putobject/&#34;&gt;putObject(bucketName, objectKey, data)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Upload an object to a bucket&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/deleteobject/&#34;&gt;deleteObject(bucketName, objectKey)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Delete an object from a bucket&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/copyobject/&#34;&gt;copyObject(sourceBucket, sourceKey, destinationBucket, destinationKey)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Copy an object from one bucket to another&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/createmultipartupload/&#34;&gt;createMultipartUpload(bucketName, objectKey)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Create a multipart upload for a given objectKey to a bucket&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/uploadpart/&#34;&gt;uploadPart(bucketName, objectKey, uploadId, partNumber, data)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Upload a part in a multipart upload&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/completemultipartupload/&#34;&gt;completeMultipartUpload(bucketName, objectKey, uploadId, parts)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Complete a previously assembled multipart upload&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/s3client/abortmultipartupload/&#34;&gt;abortMultipartUpload(bucketName, objectKey, uploadId)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Abort a multipart upload&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;S3 Client methods will throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidSignatureError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when invalid credentials were provided.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;S3ServiceError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when AWS replied to the requested operation with an error.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { check } from &amp;#39;k6&amp;#39;;
import exec from &amp;#39;k6/execution&amp;#39;;
import http from &amp;#39;k6/http&amp;#39;;

import {
  AWSConfig,
  S3Client,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/s3.js&amp;#39;;

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);
const testBucketName = &amp;#39;test-jslib-aws&amp;#39;;
const testInputFileKey = &amp;#39;productIDs.json&amp;#39;;
const testOutputFileKey = `results-${Date.now()}.json`;

export async function setup() {
  // If our test bucket does not exist, abort the execution.
  const buckets = await s3.listBuckets();
  if (buckets.filter((b) =&amp;gt; b.name === testBucketName).length == 0) {
    exec.test.abort();
  }

  // If our test object does not exist, abort the execution.
  const objects = await s3.listObjects(testBucketName);
  if (objects.filter((o) =&amp;gt; o.key === testInputFileKey).length == 0) {
    exec.test.abort();
  }

  // Download the S3 object containing our test data
  const inputObject = await s3.getObject(testBucketName, testInputFileKey);

  // Let&amp;#39;s return the downloaded S3 object&amp;#39;s data from the
  // setup function to allow the default function to use it.
  return {
    productIDs: JSON.parse(inputObject.data),
  };
}

export default async function (data) {
  // Pick a random product ID from our test data
  const randomProductID = data.productIDs[Math.floor(Math.random() * data.productIDs.length)];

  // Query our ecommerce website&amp;#39;s product page using the ID
  const res = await http.asyncRequest(&amp;#39;GET&amp;#39;, `http://your.website.com/product/${randomProductID}/`);
  check(res, { &amp;#39;is status 200&amp;#39;: res.status === 200 });
}

export async function handleSummary(data) {
  // Once the load test is over, let&amp;#39;s upload the results to our
  // S3 bucket. This is executed after teardown.
  await s3.putObject(testBucketName, testOutputFileKey, JSON.stringify(data));
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;multipart-uploads&#34;&gt;Multipart uploads&lt;/h4&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import crypto from &amp;#39;k6/crypto&amp;#39;;
import exec from &amp;#39;k6/execution&amp;#39;;

import {
  AWSConfig,
  S3Client,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/s3.js&amp;#39;;

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 s3 = new S3Client(awsConfig);

const testBucketName = &amp;#39;test-jslib-aws&amp;#39;;
const testFileKey = &amp;#39;multipart.txt&amp;#39;;

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

  // If our test bucket does not exist, abort the execution.
  if (buckets.filter((b) =&amp;gt; b.name === testBucketName).length == 0) {
    exec.test.abort();
  }

  // Produce random bytes to upload of size ~12MB, that
  // we will upload in two 6MB parts. This is done as the
  // minimum part size supported by S3 is 5MB.
  const bigFile = crypto.randomBytes(12 * 1024 * 1024);

  // Initialize a multipart upload
  const multipartUpload = await s3.createMultipartUpload(testBucketName, testFileKey);

  // Upload the first part
  const firstPartData = bigFile.slice(0, 6 * 1024 * 1024);
  const firstPart = await s3.uploadPart(
    testBucketName,
    testFileKey,
    multipartUpload.uploadId,
    1,
    firstPartData
  );

  // Upload the second part
  const secondPartData = bigFile.slice(6 * 1024 * 1024, 12 * 1024 * 1024);
  const secondPart = await s3.uploadPart(
    testBucketName,
    testFileKey,
    multipartUpload.uploadId,
    2,
    secondPartData
  );

  // Complete the multipart upload
  await s3.completeMultipartUpload(testBucketName, testFileKey, multipartUpload.uploadId, [
    firstPart,
    secondPart,
  ]);

  // Let&amp;#39;s redownload it verify it&amp;#39;s correct, and delete it
  const obj = await s3.getObject(testBucketName, testFileKey);
  await s3.deleteObject(testBucketName, testFileKey);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="s3client">S3Client&lt;/h1>
&lt;div data-shared="blocking-aws-blockquote.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>In some cases, using this library's operations might impact performance and skew your test results.
&lt;br>
&lt;br>
To ensure accurate results, consider executing these operations in the &lt;code>setup&lt;/code> and &lt;code>teardown&lt;/code>
&lt;a href="/docs/k6/v2.3.x/using-k6/test-lifecycle/">lifecycle functions&lt;/a>. These functions run before and after the test run and have no impact on the test results.&lt;/p></description></item><item><title>SecretsManagerClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/</guid><content><![CDATA[&lt;h1 id=&#34;secretsmanagerclient&#34;&gt;SecretsManagerClient&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;SecretsManagerClient&lt;/code&gt; interacts with the AWS Secrets Manager.&lt;/p&gt;
&lt;p&gt;With it, you can perform several operations such as listing, creating and downloading secrets owned by the authenticated user. For a full list of supported operations, see &lt;a href=&#34;#methods&#34;&gt;Methods&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SecretsManagerClient&lt;/code&gt; is included in both the dedicated jslib &lt;code&gt;secrets-manager.js&lt;/code&gt; bundle, and the &lt;code&gt;aws.js&lt;/code&gt; one, containing all the services clients.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/listsecrets/&#34;&gt;listSecrets()&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;List secrets owned by the authenticated user&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/getsecret/&#34;&gt;getSecret(secretID)&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Download a secret&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/createsecret/&#34;&gt;createSecret(name, secretString, description, [versionID], [tags])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Create a new secret&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/putsecretvalue/&#34;&gt;putSecretValue(secretID, secretString, [versionID])&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Update a secret&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/secretsmanagerclient/deletesecret/&#34;&gt;deleteSecret(secretID, { recoveryWindow: 30, noRecovery: false}})&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Delete a secret&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;S3 Client methods will throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidSignatureError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when invalid credentials were provided.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;SecretsManagerServiceError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when AWS replied to the requested operation with an error.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import exec from &amp;#39;k6/execution&amp;#39;;

import {
  AWSConfig,
  SecretsManagerClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/secrets-manager.js&amp;#39;;

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

const secretsManager = new SecretsManagerClient(awsConfig);
const testSecretName = &amp;#39;jslib-test-secret&amp;#39;;
const testSecretValue = &amp;#39;jslib-test-value&amp;#39;;

export async function setup() {
  // Let&amp;#39;s make sure our test secret is created
  const testSecret = await secretsManager.createSecret(
    testSecretName,
    testSecretValue,
    &amp;#39;this is a test secret, delete me.&amp;#39;
  );

  // List the secrets the AWS authentication configuration
  // gives us access to, and verify the creation was successful.
  const secrets = await secretsManager.listSecrets();
  if (!secrets.filter((s) =&amp;gt; s.name === testSecret.name).length == 0) {
    exec.test.abort(&amp;#39;test secret not found&amp;#39;);
  }
}

export default async function () {
  // Knnowing that we know the secret exist, let&amp;#39;s update its value
  const newTestSecretValue = &amp;#39;new-test-value&amp;#39;;
  await secretsManager.putSecretValue(testSecretName, newTestSecretValue);

  // Let&amp;#39;s get its value and verify it was indeed updated
  const updatedSecret = await secretsManager.getSecret(testSecretName);
  if (updatedSecret.secret !== newTestSecretValue) {
    exec.test.abort(&amp;#39;unable to update test secret&amp;#39;);
  }

  // Let&amp;#39;s now use our secret in the context of our load test...
}

export async function teardown() {
  // Finally, let&amp;#39;s clean after ourselves and delete our test secret
  await secretsManager.deleteSecret(testSecretName, { noRecovery: true });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="secretsmanagerclient">SecretsManagerClient&lt;/h1>
&lt;p>&lt;code>SecretsManagerClient&lt;/code> interacts with the AWS Secrets Manager.&lt;/p>
&lt;p>With it, you can perform several operations such as listing, creating and downloading secrets owned by the authenticated user. For a full list of supported operations, see &lt;a href="#methods">Methods&lt;/a>.&lt;/p></description></item><item><title>SignatureV4</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/signaturev4/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/signaturev4/</guid><content><![CDATA[&lt;h1 id=&#34;signaturev4&#34;&gt;SignatureV4&lt;/h1&gt;


&lt;div data-shared=&#34;blocking-aws-blockquote.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;In some cases, using this library&#39;s operations might impact performance and skew your test results.
&lt;br&gt;
&lt;br&gt;
To ensure accurate results, consider executing these operations in the &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;teardown&lt;/code&gt; 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;lifecycle functions&lt;/a&gt;. These functions run before and after the test run and have no impact on the test results.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;With SignatureV4, you can produce authenticated HTTP requests to AWS services. Namely, it lets you sign and pre-sign requests to AWS services using the &lt;a href=&#34;https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Signature V4&lt;/a&gt; algorithm. The &lt;code&gt;sign&lt;/code&gt; operation produces a signed request with authorization information stored in its headers.
The &lt;code&gt;presign&lt;/code&gt; operation produces a pre-signed request with authorization information stored in its query string parameters.&lt;/p&gt;
&lt;p&gt;SignatureV4 is included in both the dedicated jslib &lt;code&gt;signature.js&lt;/code&gt; bundle and the &lt;code&gt;aws.js&lt;/code&gt; one, containing all the service&amp;rsquo;s clients.&lt;/p&gt;
&lt;p&gt;Instantiating a new &lt;code&gt;SignatureV4&lt;/code&gt; requires a single options object argument with the following properties:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Property&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;service&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;the AWS region to sign or pre-sign requests for. As described by &lt;a href=&#34;https://docs.aws.amazon.com/general/latest/gr/rande.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Amazon AWS docs&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;region&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;the AWS service to sign or pre-sign requests for. As described by &lt;a href=&#34;https://aws.amazon.com/about-aws/global-infrastructure/regions_az/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Amazon AWS docs&lt;/a&gt;]&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;credentials&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;an object with &lt;code&gt;accessKeyId&lt;/code&gt;, &lt;code&gt;secretAccessKey&lt;/code&gt;, and optional &lt;code&gt;sessionToken&lt;/code&gt; properties&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;the AWS credentials to sign or pre-sign requests with.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;uriEscapePath&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;boolean&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Whether to uri-escape the request URI path as part of computing the canonical request string. As of late 2017, this is &lt;strong&gt;required for every AWS service&lt;/strong&gt; except Amazon S3.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;applyChecksum&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;boolean&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Whether to calculate a checksum of the request body and include it as either a request header (when signing) or as a query string parameter (when pre-signing). This is &lt;strong&gt;required for AWS Glacier and Amazon S3&lt;/strong&gt; and optional for every other AWS service as of late 2017.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;methods&#34;&gt;Methods&lt;/h2&gt;
&lt;!-- vale off --&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Method&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/signaturev4/sign/&#34;&gt;sign()&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Signs an authenticated HTTP request using the AWS signature v4 algorithm&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/signaturev4/presign/&#34;&gt;presign()&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Produces an authenticated pre-signed URL using the AWS signature v4 algorithm&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;!-- vale on --&gt;
&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;SignatureV4 methods throw errors on failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;InvalidSignatureError&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when invalid credentials were provided.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

import {
  AWSConfig,
  Endpoint,
  SignatureV4,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/signature.js&amp;#39;;

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,
});

export default function () {
  /**
   * In order to be able to sign an HTTP request&amp;#39;s,
   * we need to instantiate a SignatureV4 object.
   */
  const signer = new SignatureV4({
    service: &amp;#39;s3&amp;#39;,
    region: awsConfig.region,
    credentials: {
      accessKeyId: awsConfig.accessKeyId,
      secretAccessKey: awsConfig.secretAccessKey,
      sessionToken: awsConfig.sessionToken,
    },

    /**
     * Whether the URI should be escaped or not.
     */
    uriEscapePath: false,

    /**
     * Whether or not the body&amp;#39;s hash should be calculated and included
     * in the request.
     */
    applyChecksum: true,
  });

  /**
   * The sign operation will return a new HTTP request with the
   * AWS signature v4 protocol headers added. It returns an Object
   * implementing the SignedHTTPRequest interface, holding a `url` and a `headers`
   * properties, ready to use in the context of k6&amp;#39;s http call.
   */
  const signedRequest = signer.sign(
    /**
     * HTTP request description
     */
    {
      /**
       * The HTTP method we will use in the request.
       */
      method: &amp;#39;GET&amp;#39;,

      /**
       * The endpoint of the service we will be making the request to.
       *
       * The endpoint is instantiated from a URL string, of the format: `{scheme}://{hostname}[:{port}]`
       */
      endpoint: new Endpoint(&amp;#39;https://s3.us-east-1.amazonaws.com&amp;#39;),

      /**
       * The path of the request.
       */
      path: &amp;#39;/my-bucket/bonjour.txt&amp;#39;,

      /**
       * The query parameters to include in the request.
       */
      query: {
        &amp;#39;abc&amp;#39;: &amp;#39;123&amp;#39;,
        &amp;#39;easy as&amp;#39;: [&amp;#39;do&amp;#39;, &amp;#39;re&amp;#39;, &amp;#39;mi&amp;#39;],
      },

      /**
       * The headers we will be sending in the request.
       */
      headers: {},

      /**
       * The body of the request.
       */
      body: null,
    },

    /**
     * (optional) Signature operation options allows to override the
     * SignatureV4&amp;#39;s options in the context of this specific request.
     */
    {
      /**
       * The date and time to be used as signature metadata. This value should be
       * a Date object, a unix (epoch) timestamp, or a string that can be
       * understood by the JavaScript `Date` constructor.If not supplied, the
       * value returned by `new Date()` will be used.
       */
      signingDate: new Date(),

      /**
       * The service signing name. It will override the service name of the signer
       * in current invocation
       */
      signingService: &amp;#39;s3&amp;#39;,

      /**
       * The region name to sign the request. It will override the signing region of the
       * signer in current invocation
       */
      signingRegion: &amp;#39;us-east-1&amp;#39;,
    }
  );

  http.get(signedRequest.url, { headers: signedRequest.headers });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="signaturev4">SignatureV4&lt;/h1>
&lt;div data-shared="blocking-aws-blockquote.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>In some cases, using this library's operations might impact performance and skew your test results.
&lt;br>
&lt;br>
To ensure accurate results, consider executing these operations in the &lt;code>setup&lt;/code> and &lt;code>teardown&lt;/code>
&lt;a href="/docs/k6/v2.3.x/using-k6/test-lifecycle/">lifecycle functions&lt;/a>. These functions run before and after the test run and have no impact on the test results.&lt;/p></description></item><item><title>SQSClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/</guid><content><![CDATA[&lt;h1 id=&#34;sqsclient&#34;&gt;SQSClient&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;SQSClient&lt;/code&gt; interacts with the AWS Simple Queue Service (SQS).&lt;/p&gt;
&lt;p&gt;With it, the user can send messages to specified queues, receive messages from queues, delete processed messages, and list available queues in the current region.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SQSClient&lt;/code&gt; is included in both the dedicated &lt;code&gt;sqs.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; one, containing all the services clients.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/sendmessage/&#34;&gt;sendMessage&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Delivers a message to the specified queue.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/sendmessagebatch/&#34;&gt;sendMessageBatch&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Delivers up to ten messages to the specified queue.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/receivemessages/&#34;&gt;receiveMessages&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Receives messages from the specified queue.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/deletemessage/&#34;&gt;deleteMessage&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Deletes a message from the specified queue.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/sqsclient/listqueues/&#34;&gt;listQueues&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Returns a list of your queues in the current region.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;SQSClient&lt;/code&gt; methods throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;InvalidSignatureError&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when using invalid credentials&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;SQSServiceError&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when AWS replied to the requested operation with an error&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import exec from &amp;#39;k6/execution&amp;#39;;

import {
  AWSConfig,
  SQSClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/sqs.js&amp;#39;;

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 sqs = new SQSClient(awsConfig);
const testQueue = &amp;#39;https://sqs.us-east-1.amazonaws.com/000000000/test-queue&amp;#39;;

export default async function () {
  // If our test queue does not exist, abort the execution.
  const queuesResponse = await sqs.listQueues();
  if (queuesResponse.urls.filter((q) =&amp;gt; q === testQueue).length == 0) {
    exec.test.abort();
  }

  // Send message to test queue
  await sqs.sendMessage(testQueue, JSON.stringify({ value: &amp;#39;123&amp;#39; }));

  // Receive messages from the queue
  const messages = await sqs.receiveMessages(testQueue, {
    maxNumberOfMessages: 10,
    waitTimeSeconds: 2,
  });

  // Process and delete each received message
  for (const message of messages) {
    console.log(&amp;#39;Processing message:&amp;#39;, message.body);

    // Delete the message after processing
    await sqs.deleteMessage(testQueue, message.receiptHandle);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="sqsclient">SQSClient&lt;/h1>
&lt;p>&lt;code>SQSClient&lt;/code> interacts with the AWS Simple Queue Service (SQS).&lt;/p>
&lt;p>With it, the user can send messages to specified queues, receive messages from queues, delete processed messages, and list available queues in the current region.&lt;/p></description></item><item><title>SystemsManagerClient</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/systemsmanagerclient/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/jslib/aws/systemsmanagerclient/</guid><content><![CDATA[&lt;h1 id=&#34;systemsmanagerclient&#34;&gt;SystemsManagerClient&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;SystemsManagerClient&lt;/code&gt; interacts with the AWS Systems Manager Service.&lt;/p&gt;
&lt;p&gt;With it, the user can get parameters from the Systems Manager Service in the caller&amp;rsquo;s AWS account and region.&lt;/p&gt;
&lt;p&gt;Both the dedicated &lt;code&gt;ssm.js&lt;/code&gt; jslib bundle and the all-encompassing &lt;code&gt;aws.js&lt;/code&gt; bundle include the &lt;code&gt;SystemsManagerClient&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Function&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/aws/systemsmanagerclient/getparameter/&#34;&gt;getParameter&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Retrieves a parameter from Amazon Systems Manager.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;throws&#34;&gt;Throws&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;SystemsManagerClient&lt;/code&gt; methods throw errors in case of failure.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Error&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Condition&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;InvalidSignatureError&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when using invalid credentials&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;SystemsManagerServiceError&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;when AWS replied to the requested operation with an error&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import exec from &amp;#39;k6/execution&amp;#39;;

import {
  AWSConfig,
  SystemsManagerClient,
} from &amp;#39;https://jslib.k6.io/aws/0.14.0/ssm.js&amp;#39;;

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 systemsManager = new SystemsManagerClient(awsConfig);
const testParameterName = &amp;#39;jslib-test-parameter&amp;#39;;
const testParameterValue = &amp;#39;jslib-test-value&amp;#39;;
const testParameterSecretName = &amp;#39;jslib-test-parameter-secret&amp;#39;;
// this value was created with --type SecureString
const testParameterSecretValue = &amp;#39;jslib-test-secret-value&amp;#39;;

export default async function () {
  // Currently the parameter needs to be created before hand

  // Let&amp;#39;s get its value
  // getParameter returns a parameter object: e.g. {name: string, value: string...}
  const parameter = await systemsManager.getParameter(testParameterName);
  if (parameter.value !== testParameterValue) {
    exec.test.abort(&amp;#39;test parameter not found&amp;#39;);
  }

  // Let&amp;#39;s get the secret value with decryption
  // destructure the parameter object to get to the values you want
  const { value: encryptedParameterValue } = await systemsManager.getParameter(
    testParameterSecretName,
    true
  );
  if (encryptedParameterValue !== testParameterSecretValue) {
    exec.test.abort(&amp;#39;encrypted test parameter not found&amp;#39;);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;A k6 script querying a user&amp;rsquo;s Systems Manager Service parameter&lt;/em&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="systemsmanagerclient">SystemsManagerClient&lt;/h1>
&lt;p>&lt;code>SystemsManagerClient&lt;/code> interacts with the AWS Systems Manager Service.&lt;/p>
&lt;p>With it, the user can get parameters from the Systems Manager Service in the caller&amp;rsquo;s AWS account and region.&lt;/p></description></item></channel></rss>