Utilizzare ListFunctions con un SDK AWS o una CLI
Gli esempi di codice seguenti mostrano come utilizzare ListFunctions.
Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:
- .NET
-
- SDK per .NET
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. /// <summary> /// Get a list of Lambda functions. /// </summary> /// <returns>A list of FunctionConfiguration objects.</returns> public async Task<List<FunctionConfiguration>> ListFunctionsAsync() { var functionList = new List<FunctionConfiguration>(); var functionPaginator = _lambdaService.Paginators.ListFunctions(new ListFunctionsRequest()); await foreach (var function in functionPaginator.Functions) { functionList.Add(function); } return functionList; }-
Per informazioni dettagliate sull'API, consulta la sezione ListFunctions nella Documentazione di riferimento delle API AWS SDK per .NET.
-
- C++
-
- SDK per C++
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region in which the bucket was created (overrides config file). // clientConfig.region = "us-east-1"; Aws::Lambda::LambdaClient client(clientConfig); std::vector<Aws::String> functions; Aws::String marker; do { Aws::Lambda::Model::ListFunctionsRequest request; if (!marker.empty()) { request.SetMarker(marker); } Aws::Lambda::Model::ListFunctionsOutcome outcome = client.ListFunctions( request); if (outcome.IsSuccess()) { const Aws::Lambda::Model::ListFunctionsResult &result = outcome.GetResult(); std::cout << result.GetFunctions().size() << " lambda functions were retrieved." << std::endl; for (const Aws::Lambda::Model::FunctionConfiguration &functionConfiguration: result.GetFunctions()) { functions.push_back(functionConfiguration.GetFunctionName()); std::cout << functions.size() << " " << functionConfiguration.GetDescription() << std::endl; std::cout << " " << Aws::Lambda::Model::RuntimeMapper::GetNameForRuntime( functionConfiguration.GetRuntime()) << ": " << functionConfiguration.GetHandler() << std::endl; } marker = result.GetNextMarker(); } else { std::cerr << "Error with Lambda::ListFunctions. " << outcome.GetError().GetMessage() << std::endl; } } while (!marker.empty());-
Per informazioni dettagliate sull'API, consulta la sezione ListFunctions nella Documentazione di riferimento delle API AWS SDK per C++.
-
- CLI
-
- AWS CLI
-
Come recuperare un elenco di funzioni Lambda
L'esempio di
list-functionsseguente visualizza un elenco di tutte le funzioni per l'utente attuale.aws lambda list-functionsOutput:
{ "Functions": [ { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "dBG9m8SGdmlEjw/JYXlhhvCrAv5TxvXsbL/RMr0fT/I=", "FunctionName": "helloworld", "MemorySize": 128, "RevisionId": "1718e831-badf-4253-9518-d0644210af7b", "CodeSize": 294, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:helloworld", "Handler": "helloworld.handler", "Role": "arn:aws:iam::123456789012:role/service-role/MyTestFunction-role-zgur6bf4", "Timeout": 3, "LastModified": "2025-09-23T18:32:33.857+0000", "Runtime": "nodejs22.x", "Description": "" }, { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "sU0cJ2/hOZevwV/lTxCuQqK3gDZP3i8gUoqUUVRmY6E=", "FunctionName": "my-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 256, "RevisionId": "93017fc9-59cb-41dc-901b-4845ce4bf668", "CodeSize": 266, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "Handler": "index.handler", "Role": "arn:aws:iam::123456789012:role/service-role/helloWorldPython-role-uy3l9qyq", "Timeout": 3, "LastModified": "2025-10-01T16:47:28.490+0000", "Runtime": "nodejs22.x", "Description": "" }, { "Layers": [ { "CodeSize": 41784542, "Arn": "arn:aws:lambda:us-west-2:420165488524:layer:AWSLambda-Python37-SciPy1x:2" }, { "CodeSize": 4121, "Arn": "arn:aws:lambda:us-west-2:123456789012:layer:pythonLayer:1" } ], "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "ZQukCqxtkqFgyF2cU41Avj99TKQ/hNihPtDtRcc08mI=", "FunctionName": "my-python-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 128, "RevisionId": "80b4eabc-acf7-4ea8-919a-e874c213707d", "CodeSize": 299, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-python-function", "Handler": "lambda_function.lambda_handler", "Role": "arn:aws:iam::123456789012:role/service-role/my-python-function-role-z5g7dr6n", "Timeout": 3, "LastModified": "2025-10-01T19:40:41.643+0000", "Runtime": "python3.11", "Description": "" } ] }Per ulteriori informazioni, consulta Configurazione della memoria della funzione Lambda nella Guida per gli sviluppatori Lambda AWS.
-
Per informazioni dettagliate sull'API, consulta ListFunctions
nella Documentazione di riferimento dei comandi della AWS CLI.
-
- Go
-
- SDK per Go V2
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. import ( "bytes" "context" "encoding/json" "errors" "log" "time" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/lambda" "github.com/aws/aws-sdk-go-v2/service/lambda/types" ) // FunctionWrapper encapsulates function actions used in the examples. // It contains an AWS Lambda service client that is used to perform user actions. type FunctionWrapper struct { LambdaClient *lambda.Client } // ListFunctions lists up to maxItems functions for the account. This function uses a // lambda.ListFunctionsPaginator to paginate the results. func (wrapper FunctionWrapper) ListFunctions(ctx context.Context, maxItems int) []types.FunctionConfiguration { var functions []types.FunctionConfiguration paginator := lambda.NewListFunctionsPaginator(wrapper.LambdaClient, &lambda.ListFunctionsInput{ MaxItems: aws.Int32(int32(maxItems)), }) for paginator.HasMorePages() && len(functions) < maxItems { pageOutput, err := paginator.NextPage(ctx) if err != nil { log.Panicf("Couldn't list functions for your account. Here's why: %v\n", err) } functions = append(functions, pageOutput.Functions...) } return functions }-
Per informazioni dettagliate sull'API, consulta la sezione ListFunctions
nella Documentazione di riferimento delle API AWS SDK per Go.
-
- JavaScript
-
- SDK per JavaScript (v3)
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. const listFunctions = () => { const client = new LambdaClient({}); const command = new ListFunctionsCommand({}); return client.send(command); };-
Per informazioni dettagliate sull'API, consulta la sezione ListFunctions nella Documentazione di riferimento delle API AWS SDK per JavaScript.
-
- PHP
-
- SDK per PHP
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. public function listFunctions($maxItems = 50, $marker = null) { if (is_null($marker)) { return $this->lambdaClient->listFunctions([ 'MaxItems' => $maxItems, ]); } return $this->lambdaClient->listFunctions([ 'Marker' => $marker, 'MaxItems' => $maxItems, ]); }-
Per informazioni dettagliate sull'API, consulta la sezione ListFunctions nella Documentazione di riferimento delle API AWS SDK per PHP.
-
- PowerShell
-
- Strumenti per PowerShell V4
-
Esempio 1: questo esempio mostra tutte le funzioni Lambda con dimensioni di codice ordinate
Get-LMFunctionList | Sort-Object -Property CodeSize | Select-Object FunctionName, RunTime, Timeout, CodeSizeOutput:
FunctionName Runtime Timeout CodeSize ------------ ------- ------- -------- test python2.7 3 243 MylambdaFunction123 python3.8 600 659 myfuncpython1 python3.8 303 675-
Per informazioni dettagliate sull’API, consulta ListFunctions nella documentazione di riferimento dei cmdlet di AWS Strumenti per PowerShell (V4).
-
- Strumenti per PowerShell V5
-
Esempio 1: questo esempio mostra tutte le funzioni Lambda con dimensioni di codice ordinate
Get-LMFunctionList | Sort-Object -Property CodeSize | Select-Object FunctionName, RunTime, Timeout, CodeSizeOutput:
FunctionName Runtime Timeout CodeSize ------------ ------- ------- -------- test python2.7 3 243 MylambdaFunction123 python3.8 600 659 myfuncpython1 python3.8 303 675-
Per informazioni dettagliate sull’API, consulta ListFunctions nella documentazione di riferimento dei cmdlet di AWS Strumenti per PowerShell (V5).
-
- Python
-
- SDK per Python (Boto3)
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. class LambdaWrapper: def __init__(self, lambda_client, iam_resource): self.lambda_client = lambda_client self.iam_resource = iam_resource def list_functions(self): """ Lists the Lambda functions for the current account. """ try: func_paginator = self.lambda_client.get_paginator("list_functions") for func_page in func_paginator.paginate(): for func in func_page["Functions"]: print(func["FunctionName"]) desc = func.get("Description") if desc: print(f"\t{desc}") print(f"\t{func['Runtime']}: {func['Handler']}") except ClientError as err: logger.error( "Couldn't list functions. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise-
Per informazioni dettagliate sulle API, consulta ListFunctions nella Documentazione di riferimento delle API SDK AWS per Python (Boto3).
-
- Ruby
-
- SDK per Ruby
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. class LambdaWrapper attr_accessor :lambda_client, :cloudwatch_client, :iam_client def initialize @lambda_client = Aws::Lambda::Client.new @cloudwatch_client = Aws::CloudWatchLogs::Client.new(region: 'us-east-1') @iam_client = Aws::IAM::Client.new(region: 'us-east-1') @logger = Logger.new($stdout) @logger.level = Logger::WARN end # Lists the Lambda functions for the current account. def list_functions functions = [] @lambda_client.list_functions.each do |response| response['functions'].each do |function| functions.append(function['function_name']) end end functions rescue Aws::Lambda::Errors::ServiceException => e @logger.error("There was an error listing functions:\n #{e.message}") end-
Per informazioni dettagliate sull'API, consulta la sezione ListFunctions nella Documentazione di riferimento delle API AWS SDK per Ruby.
-
- Rust
-
- SDK per Rust
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. /** List all Lambda functions in the current Region. */ pub async fn list_functions(&self) -> Result<ListFunctionsOutput, anyhow::Error> { info!("Listing lambda functions"); self.lambda_client .list_functions() .send() .await .map_err(anyhow::Error::from) }-
Per informazioni dettagliate sull'API, consulta la pagina ListFunctions
della documentazione di riferimento dell'API SDK AWS per Rust.
-
- SAP ABAP
-
- SDK per SAP ABAP
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. TRY. oo_result = lo_lmd->listfunctions( ). " oo_result is returned for testing purposes. " DATA(lt_functions) = oo_result->get_functions( ). MESSAGE 'Retrieved list of Lambda functions.' TYPE 'I'. CATCH /aws1/cx_lmdinvparamvalueex. MESSAGE 'The request contains a non-valid parameter.' TYPE 'E'. CATCH /aws1/cx_lmdserviceexception. MESSAGE 'An internal problem was encountered by the AWS Lambda service.' TYPE 'E'. CATCH /aws1/cx_lmdtoomanyrequestsex. MESSAGE 'The maximum request throughput was reached.' TYPE 'E'. ENDTRY.-
Per informazioni dettagliate sull'API, consulta ListFunctions nella Documentazione di riferimento delle API SDK AWS per SAP ABAP.
-
- Swift
-
- SDK per Swift
-
Nota
Ulteriori informazioni su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. import AWSClientRuntime import AWSLambda import Foundation /// Returns an array containing the names of all AWS Lambda functions /// available to the user. /// /// - Parameter lambdaClient: The `IAMClient` to use. /// /// - Throws: `ExampleError.listFunctionsError` /// /// - Returns: An array of lambda function name strings. func getFunctionNames(lambdaClient: LambdaClient) async throws -> [String] { let pages = lambdaClient.listFunctionsPaginated( input: ListFunctionsInput() ) var functionNames: [String] = [] for try await page in pages { guard let functions = page.functions else { throw ExampleError.listFunctionsError } for function in functions { functionNames.append(function.functionName ?? "<unknown>") } } return functionNames }-
Per informazioni dettagliate sull’API, consulta ListFunctions
nella documentazione di riferimento dell’API AWS SDK per Swift.
-
Per un elenco completo delle guide per gli sviluppatori di SDK AWS ed esempi di codice, consulta la sezione Utilizzo di Lambda con un SDK AWS. Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell'SDK.