PluginBench
Skill
Pass
Audit score 90

aws-sdk-java-v2-lambda

giuseppe-trisciuoglio/developer-kit

Invoke, deploy, and manage AWS Lambda functions from Java applications using AWS SDK 2.x

What is aws-sdk-java-v2-lambda?

Provides AWS Lambda patterns using AWS SDK for Java 2.x. Use this skill when invoking Lambda functions, creating or updating functions, managing configurations and layers, or integrating Lambda with Spring Boot applications.

  • Invoke Lambda functions synchronously and asynchronously
  • Create, update, and delete Lambda functions via SDK
  • Manage function configurations, environment variables, and concurrency limits
  • Work with Lambda layers and function deployments
  • Integrate Lambda operations into Spring Boot services
  • Handle response payloads and error checking

How to install aws-sdk-java-v2-lambda

npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-lambda
Prerequisites
  • AWS SDK for Java 2.x Lambda dependency in pom.xml
  • AWS credentials configured (IAM role or credentials file)
  • Java 8 or later runtime
Claude Code
Cursor
Windsurf
Cline

How to use aws-sdk-java-v2-lambda

  1. 1.Add the Lambda SDK dependency to your pom.xml
  2. 2.Create a LambdaClient instance with region configuration
  3. 3.Build InvokeRequest objects specifying function name and payload
  4. 4.Call lambdaClient.invoke() and handle the InvokeResponse
  5. 5.For function management, use createFunction(), updateFunctionCode(), or updateFunctionConfiguration()
  6. 6.Verify function state is Active before proceeding with operations
  7. 7.For Spring Boot, configure LambdaClient as a bean in your configuration class

Use cases

Good for
  • Calling Lambda functions from Java microservices to process events
  • Deploying and updating Lambda function code programmatically
  • Setting environment variables and resource limits on Lambda functions
  • Building Spring Boot services that orchestrate Lambda invocations
  • Automating Lambda function lifecycle management in CI/CD pipelines
Who it's for
  • Java developers building serverless integrations
  • Spring Boot application developers
  • DevOps engineers automating Lambda deployments
  • Backend engineers invoking Lambda from microservices

aws-sdk-java-v2-lambda FAQ

What is the maximum payload size for Lambda invocations?

Synchronous invocations support up to 6MB payloads, while asynchronous (EVENT) invocations are limited to 256KB.

Should I create a new LambdaClient for each invocation?

No. LambdaClient is thread-safe and should be reused. Create it once and share across your application.

How do I invoke Lambda asynchronously?

Set invocationType to InvocationType.EVENT in the InvokeRequest. This returns immediately without waiting for the function to complete.

What should I do after creating or updating a Lambda function?

Always verify the function state is Active using getFunction() or wait using the SDK's waiter before proceeding with further operations.

How do I set environment variables on a Lambda function?

Use updateFunctionConfiguration() with an Environment object containing your key-value pairs.

Full instructions (SKILL.md)

Source of truth, from giuseppe-trisciuoglio/developer-kit.


name: aws-sdk-java-v2-lambda description: Provides AWS Lambda patterns using AWS SDK for Java 2.x. Use when invoking Lambda functions, creating/updating functions, managing function configurations, working with Lambda layers, or integrating Lambda with Spring Boot applications. allowed-tools: Read, Write, Edit, Bash, Glob, Grep

AWS SDK for Java 2.x - AWS Lambda

Overview

AWS Lambda is a compute service that runs code without managing servers. Use this skill to implement AWS Lambda operations using AWS SDK for Java 2.x in applications and services.

When to Use

  • Invoking Lambda functions from Java applications
  • Deploying and updating Lambda functions via SDK
  • Managing function configurations and layers
  • Integrating Lambda with Spring Boot applications

Quick Reference

OperationSDK MethodUse Case
Invokeinvoke()Synchronous/async function invocation
List FunctionslistFunctions()Get all Lambda functions
Get ConfiggetFunction()Retrieve function configuration
Create FunctioncreateFunction()Create new Lambda function
Update CodeupdateFunctionCode()Deploy new function code
Update ConfigupdateFunctionConfiguration()Modify settings (timeout, memory, env vars)
Delete FunctiondeleteFunction()Remove Lambda function

Instructions

1. Add Dependencies

Include Lambda SDK dependency in pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>lambda</artifactId>
</dependency>

See client-setup.md for complete setup.

2. Create Client

Instantiate LambdaClient with proper configuration:

LambdaClient lambdaClient = LambdaClient.builder()
    .region(Region.US_EAST_1)
    .build();

For async operations, use LambdaAsyncClient.

3. Invoke Lambda Function

Synchronous invocation:

InvokeRequest request = InvokeRequest.builder()
    .functionName("my-function")
    .payload(SdkBytes.fromUtf8String(payload))
    .build();

InvokeResponse response = lambdaClient.invoke(request);

return response.payload().asUtf8String();

See invocation-patterns.md for patterns.

4. Handle Responses

Parse response payloads and check for errors:

if (response.functionError() != null) {
    throw new LambdaInvocationException("Lambda error: " + response.functionError());
}

String result = response.payload().asUtf8String();

5. Manage Functions

Create, update, or delete Lambda functions:

// Create
CreateFunctionRequest createRequest = CreateFunctionRequest.builder()
    .functionName("my-function")
    .runtime(Runtime.JAVA17)
    .role(roleArn)
    .code(code)
    .build();

lambdaClient.createFunction(createRequest);

// Verify function is active before proceeding
GetFunctionRequest getRequest = GetFunctionRequest.builder()
    .functionName("my-function")
    .build();
GetFunctionResponse getResponse = lambdaClient.getFunction(getRequest);
if (!"Active".equals(getResponse.configuration().state())) {
    throw new IllegalStateException("Function not active: " + getResponse.configuration().stateReason());
}

// Update code
UpdateFunctionCodeRequest updateCodeRequest = UpdateFunctionCodeRequest.builder()
    .functionName("my-function")
    .zipFile(SdkBytes.fromByteArray(zipBytes))
    .build();

lambdaClient.updateFunctionCode(updateCodeRequest);

// Wait for deployment to complete
Waiter<GetFunctionConfigurationRequest> waiter = lambdaClient.waiter();
waiter.waitUntilFunctionUpdatedActive(GetFunctionConfigurationRequest.builder()
    .functionName("my-function")
    .build());

See function-management.md for complete patterns.

6. Configure Environment

Set environment variables and concurrency limits:

Environment env = Environment.builder()
    .variables(Map.of(
        "DB_URL", "jdbc:postgresql://db",
        "LOG_LEVEL", "INFO"
    ))
    .build();

UpdateFunctionConfigurationRequest configRequest = UpdateFunctionConfigurationRequest.builder()
    .functionName("my-function")
    .environment(env)
    .timeout(60)
    .memorySize(512)
    .build();

lambdaClient.updateFunctionConfiguration(configRequest);

7. Integrate with Spring Boot

Configure Lambda beans and services:

@Configuration
public class LambdaConfiguration {
    @Bean
    public LambdaClient lambdaClient() {
        return LambdaClient.builder()
            .region(Region.US_EAST_1)
            .build();
    }
}

@Service
public class LambdaInvokerService {
    public <T, R> R invoke(String functionName, T request, Class<R> responseType) {
        // Implementation
    }
}

See spring-boot-integration.md for complete integration.

8. Test Locally

Use mocks or LocalStack for development testing.

See testing.md for testing patterns.

Examples

Basic Invocation

public String invokeFunction(LambdaClient client, String functionName, String payload) {
    InvokeRequest request = InvokeRequest.builder()
        .functionName(functionName)
        .payload(SdkBytes.fromUtf8String(payload))
        .build();

    InvokeResponse response = client.invoke(request);

    if (response.functionError() != null) {
        throw new RuntimeException("Lambda error: " + response.functionError());
    }

    return response.payload().asUtf8String();
}

Async Invocation

public void invokeAsync(LambdaClient client, String functionName, Map<String, Object> event) {
    String jsonPayload = new ObjectMapper().writeValueAsString(event);

    InvokeRequest request = InvokeRequest.builder()
        .functionName(functionName)
        .invocationType(InvocationType.EVENT)
        .payload(SdkBytes.fromUtf8String(jsonPayload))
        .build();

    client.invoke(request);
}

Spring Boot Service

@Service
public class LambdaService {
    private final LambdaClient lambdaClient;

    public UserResponse processUser(UserRequest request) {
        String payload = objectMapper.writeValueAsString(request);

        InvokeResponse response = lambdaClient.invoke(
            InvokeRequest.builder()
                .functionName("user-processor")
                .payload(SdkBytes.fromUtf8String(payload))
                .build()
        );

        return objectMapper.readValue(
            response.payload().asUtf8String(),
            UserResponse.class
        );
    }
}

See examples.md for more examples.

Best Practices

  • Reuse clients: Create LambdaClient/LambdaAsyncClient once; they are thread-safe
  • Use async client: For fire-and-forget invocations, use LambdaAsyncClient with CompletableFuture
  • Verify deployments: Always wait for function state to be Active after create/update operations
  • Limit payload size: Keep request/response payloads under 256KB for async, 6MB for sync invocations
  • Configure timeouts: Set client read timeout slightly higher than Lambda function timeout
  • Use latest runtime: Specify Runtime.JAVA17 or newer for improved cold start performance

Constraints and Warnings

  • Payload Limit: 6MB (sync), 256KB (async invocation)
  • Timeout: Max 900 seconds (15 minutes) per invocation
  • Cold Starts: JVM-based functions have longer cold starts; use GraalVM Native Image for improvement
  • Deployment Size: Function code + layers must not exceed 50MB (zipped) or 250MB (unzipped)
  • Concurrency: Default 1000 per region; use reserved concurrency to guarantee capacity
  • Cost: Monitor with CloudWatch metrics; set billing alerts to prevent runaway costs

References

Related Skills

  • aws-sdk-java-v2-core — Core AWS SDK patterns and client configuration
  • spring-boot-dependency-injection — Spring dependency injection best practices
  • unit-test-service-layer — Service testing patterns with Mockito
  • spring-boot-actuator — Production monitoring and health checks

External Resources

Related skills

More from giuseppe-trisciuoglio/developer-kit and the wider catalog.