AWSLambdaClient is the synchronous client from version 1 of the AWS SDK for Java. It sends Invoke, CreateFunction, ListFunctions and other API calls to AWS Lambda. That SDK line is end-of-support, so new Spring Boot code should use LambdaClient from AWS SDK for Java 2.x, which does the same job with a builder, a modern HTTP stack and a default credentials chain.
Spring Boot has no Lambda-specific auto-configuration, so you declare the client as a bean and inject it into your services.
com.amazonaws.services.lambda.AWSLambdaClient implements the AWSLambda interface of the v1 SDK (aws-java-sdk-lambda). Each method maps to one Lambda API operation, for example invoke(InvokeRequest) returning an InvokeResult. Direct construction of AWSLambdaClient is deprecated even in v1; the supported way was AWSLambdaClientBuilder.
AWS has ended support for the v1 SDK for Java, so it no longer receives fixes. The replacement is the v2 client, shown below.
| Aspect | v1 AWSLambdaClient | v2 LambdaClient |
|---|---|---|
| Package | com.amazonaws.services.lambda | software.amazon.awssdk.services.lambda |
| Creation | AWSLambdaClientBuilder.standard() | LambdaClient.builder() |
| Request objects | Mutable (new InvokeRequest().withFunctionName(..)) | Immutable builders |
| Payload type | ByteBuffer | SdkBytes |
| Async variant | AWSLambdaAsyncClient | LambdaAsyncClient |
Import the AWS SDK v2 bill of materials so every module uses a matching version, then add the Lambda module.
Set aws.sdk.version to the current 2.x release listed on Maven Central.
Create one client for the whole application. The clients are thread-safe and hold a connection pool, so do not build one per request.
No credentials appear in code. The builder uses the default credentials provider chain: environment variables, shared profile files, container credentials or the IAM role of the EC2 instance, ECS task or EKS pod. Give that role the lambda:InvokeFunction permission on the functions you call and nothing broader.
The following service sends a JSON payload synchronously and reads the response.
An important detail: when your function throws, the API call itself still succeeds with HTTP 200. The failure is reported in functionError(), so you must check it. Infrastructure problems such as missing permissions or throttling are thrown as LambdaException (or the more specific TooManyRequestsException).
InvokeRequest takes an invocationType. REQUEST_RESPONSE (default) waits for the result, EVENT queues the call and returns immediately with status 202, and DRY_RUN only validates permissions and parameters. Use EVENT for fire-and-forget work, but remember that Lambda retries failed asynchronous events, so the function should be idempotent.
The synchronous Invoke call is limited by the function timeout, which can be up to 15 minutes, and the request payload is limited to 6 MB for synchronous calls. Set the client timeouts so they are slightly above the function timeout.
The SDK retries throttling and transient network errors by default. Do not add a second retry layer on top for non-idempotent functions.
Hide the client behind a small interface in your own code and mock it in unit tests. For integration tests, LocalStack or Testcontainers can provide a Lambda endpoint; point the client at it with endpointOverride(URI.create("http://localhost:4566")).
No. It belongs to AWS SDK for Java 1.x, which has reached end of support. Migrate to LambdaClient from SDK 2.x.
Yes, through API Gateway or a Lambda function URL using RestClient or WebClient. The SDK is simpler when you need IAM-signed calls and the full Lambda API.
Use LambdaAsyncClient when you need non-blocking calls, for example in a reactive application. With virtual threads on Java 21 or later the blocking client is also a fine choice.
From the default provider chain, never from code. On AWS, attach an IAM role to the compute resource.
AWSLambdaClient is the legacy v1 way to call AWS Lambda. In Spring Boot today, add the AWS SDK v2 BOM, expose a single LambdaClient bean, grant a least-privilege IAM role, and always check functionError() after an invocation.