Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

aws-sdk-java-v2-lambda

/aws-sdk-java-v2-lambda

Dostarcza wzorce AWS Lambda z AWS SDK for Java 2.x: wywoływanie, tworzenie i aktualizacja funkcji, konfiguracje, warstwy Lambda i integracja ze Spring Boot.

Repozytorium
developer-kit ↗
Licencja
MIT
Ostatnia zmiana repozytorium
10.09.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
8
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
3
Przestarzałość

Brak sygnałów. Repozytorium zmienione 10.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Dostarcza wzorce AWS Lambda z AWS SDK for Java 2.x: wywoływanie, tworzenie i aktualizacja funkcji, konfiguracje, warstwy Lambda i integracja ze Spring Boot.

Oryginalny opis (EN)

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.

Jak działa

  1. Overview
  2. When to Use
  3. Quick Reference
  4. Instructions
  5. Examples
  6. Best Practices
  7. Constraints and Warnings
  8. References
  9. Related Skills
  10. External Resources
Sekcje z nagłówków SKILL.md, w oryginale · 281 linii, 831 słów
Podgląd SKILL.md
---
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

| Operation | SDK Method | Use Case |
|-----------|------------|----------|
| **Invoke** | `invoke()` | Synchronous/async function invocation |
| **List Functions** | `listFunctions()` | Get all Lambda functions |
| **Get Config** | `getFunction()` | Retrieve function configuration |
| **Create Function** | `createFunction()` | Create new Lambda function |
| **Update Code** | `updateFunctionCode()` | Deploy new function code |
| **Update Config** | `updateFunctionConfiguration()` | Modify settings (timeout, memory, env vars) |
| **Delete Function** | `deleteFunction()` | Remove Lambda function |

## Instructions

### 1. Add Dependencies

Include Lambda SDK dependency in `pom.xml`:

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

See [client-setup.md](references/client-setup.md) for complete setup.

### 2. Create Client

Instantiate `LambdaClient` with proper configuration:

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

For async operations, use `LambdaAsyncClient`.

### 3. Invoke Lambda Function

Synchronous invocation:

```java
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](references/invocation-patterns.md) for patterns.

### 4. Handle Responses

Parse response payloads and check for errors:

```java
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:

```java
// 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](references/function-management.md) for complete patterns.

### 6. Configure Environment

Set environment variables and concurrency limits:

```java
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:

```java
@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](references/spring-boot-integration.md) for complete integration.

### 8. Test Locally

Use mocks or LocalStack for development testing.

See [testing.md](references/testing.md) for testing patterns.

## Examples

### Basic Invocation

```java
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

```java
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

```java
@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](references/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

- **[client-setup.md](references/client-setup.md)** — Client configuration and setup
- **[invocation-patterns.md](references/invocation-patterns.md)** — Synchronous and async invocation patterns
- **[function-management.md](references/function-management.md)** — Create, update, delete functions
- **[spring-boot-integration.md](references/spring-boot-integration.md)** — Spring Boot configuration and services
- **[testing.md](references/testing.md)** — Unit and integration testing patterns
- **[examples.md](references/examples.md)** — Complete code examples and integration patterns
- **[official-documentation.md](references/official-documentation.md)** — AWS Lambda concepts and API reference

## 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

- [Lambda Examples on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/lambda)
- [Lambda API Reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/lambda/package-summary.html)
- [AWS Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)
Pliki w paczce (8)
  • SKILL.md 9 KB
  • references/client-setup.md 2 KB
  • references/examples.md 17 KB
  • references/function-management.md 7 KB
  • references/invocation-patterns.md 7 KB
  • references/official-documentation.md 4 KB
  • references/spring-boot-integration.md 8 KB
  • references/testing.md 8 KB

Wersje

W bazie nie ma innych skilli o nazwie aws-sdk-java-v2-lambda.

Migawka bazy z 28.10.2026 · wersja paczki df8587259128 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100aws-sdk-java-v2-dynamodb
    Dostarcza wzorce Amazon DynamoDB z AWS SDK for Java 2.x: tworzenie, zapytania, skanowanie i CRUD tabel, indeksy, operacje wsadowe, transakcje i integracja ze Spring Boot.
  • 100aws-lambda-java-integration
    Dostarcza wzorce integracji AWS Lambda z Javą i optymalizacją cold startów poniżej sekundy: wybór między Micronaut a czystą Javą oraz integracja z API Gateway lub ALB.
  • 100lambda
    Projektuje, buduje i optymalizuje funkcje AWS Lambda: zimne starty, źródła zdarzeń, wydajność, warstwy, współbieżność i strategie wdrażania.
  • 100aws-lambda
    Buduje i wdraża funkcje serverless w AWS Lambda, konfiguruje wyzwalacze, zarządza uprawnieniami i optymalizuje wydajność aplikacji serverless.
  • 100aws-lambda
    Buduje i wdraża funkcje serverless w AWS Lambda, konfiguruje wyzwalacze, zarządza uprawnieniami i optymalizuje wydajność aplikacji serverless.
  • 100aws-lambda
    Buduje i wdraża funkcje serverless w AWS Lambda, konfiguruje wyzwalacze, zarządza uprawnieniami i optymalizuje wydajność aplikacji serverless.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.