Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/javascript-api/jslib/aws/lambdaclient.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/javascript-api/jslib/aws/lambdaclient/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
LambdaClient
Caution
In some cases, using this library's operations might impact performance and skew your test results.
To ensure accurate results, consider executing these operations in thesetupandteardownlifecycle functions. These functions run before and after the test run and have no impact on the test results.
LambdaClient interacts with AWS Lambda. With it, you can invoke a Lambda function.
Both the dedicated lambda.js jslib bundle and the all-encompassing aws.js bundle include the LambdaClient.
Methods
| Function | Description |
|---|---|
| invoke(name, payload, [options]) | Invokes an AWS Lambda function. |
Throws
LambdaClient methods will throw errors in case of failure.
| Error | Condition |
|---|---|
| InvalidSignatureError | When invalid credentials were provided. |
| LambdaInvocationError | When AWS replied to the requested invocation with an error. |
Examples
import {
AWSConfig,
LambdaClient,
} from 'https://jslib.k6.io/aws/0.14.0/lambda.js';
import { check } from 'k6';
const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
accessKeyId: __ENV.AWS_ACCESS_KEY_ID,
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,
sessionToken: __ENV.AWS_SESSION_TOKEN,
});
const lambdaClient = new LambdaClient(awsConfig);
export default async function () {
const response = await lambdaClient.invoke('add-numbers', JSON.stringify({ x: 1, y: 2 }));
check(response, {
'status is 200': (r) => r.statusCode === 200,
'payload is 3': (r) => r.payload === 3,
});
}Was this page helpful?
Related resources from Grafana Labs

