0

List Lambda functions

by
Published today

List one page of Lambda functions in the resource's region, with the marker for the next page.

Script aws_lambda Verified

The script

Submitted by hugo989 Bun
Verified 2 hours ago
1
import { LambdaClient, ListFunctionsCommand } from "@aws-sdk/client-lambda"
2

3
/**
4
 * List Lambda functions
5
 * List one page of the Lambda functions in the resource's region (at most 50 per page). Pass the returned NextMarker as marker to fetch the next page; NextMarker is absent on the last page. Needs lambda:ListFunctions.
6
 */
7
export async function main(
8
  auth: RT.Aws,
9
  max_items: number | undefined,
10
  marker: string | undefined,
11
  function_version: "ALL" | undefined
12
) {
13
  const client = new LambdaClient({
14
    region: auth.region || undefined,
15
    credentials: {
16
      accessKeyId: auth.awsAccessKeyId,
17
      secretAccessKey: auth.awsSecretAccessKey,
18
    },
19
  })
20

21
  const { $metadata, ...result } = await client.send(
22
    new ListFunctionsCommand({
23
      MaxItems: max_items || undefined,
24
      Marker: marker || undefined,
25
      FunctionVersion: function_version || undefined,
26
    })
27
  )
28
  return {
29
    Functions: result.Functions ?? [],
30
    NextMarker: result.NextMarker ?? null,
31
  }
32
}
33