0

Get Lambda function

by
Published today

Get a Lambda function's configuration, deployment package link, tags and reserved concurrency.

Script aws_lambda Verified

The script

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

3
/**
4
 * Get Lambda function
5
 * Get a Lambda function's configuration, a presigned link to its deployment package (valid 10 minutes), its tags and its reserved concurrency. Pass a qualifier to read a specific version or alias. Needs lambda:GetFunction (tags also need lambda:ListTags).
6
 */
7
export async function main(
8
  auth: RT.Aws,
9
  function_name: string,
10
  qualifier: string | undefined
11
) {
12
  const client = new LambdaClient({
13
    region: auth.region || undefined,
14
    credentials: {
15
      accessKeyId: auth.awsAccessKeyId,
16
      secretAccessKey: auth.awsSecretAccessKey,
17
    },
18
  })
19

20
  const { $metadata, ...result } = await client.send(
21
    new GetFunctionCommand({
22
      FunctionName: function_name,
23
      Qualifier: qualifier || undefined,
24
    })
25
  )
26
  return result
27
}
28