aws-lambda-java-integration
Provides AWS Lambda integration patterns for Java with cold start optimization. Use when deploying Java functions to AWS Lambda, choosing between Micronaut and Raw Java approaches, optimizing cold starts below 1 second, configuring API Gateway or ALB integration, or implementing serverless Java applications. Triggers include "create lambda java", "deploy java lambda", "micronaut lambda aws", "java lambda cold start", "aws lambda java performance", "java serverless framework".
What this skill does
# AWS Lambda Java Integration
Patterns for creating high-performance AWS Lambda functions in Java with optimized cold starts.
## Overview
This skill provides complete patterns for AWS Lambda Java development, covering two main approaches:
1. **Micronaut Framework** - Full-featured framework with AOT compilation, dependency injection, and cold start < 1s
2. **Raw Java** - Minimal overhead approach with cold start < 500ms
Both approaches support API Gateway and ALB integration with production-ready configurations.
## When to Use
- Deploying Java functions to AWS Lambda
- Optimizing cold starts below 1 second
- Choosing between Micronaut and Raw Java approaches
- Configuring API Gateway or ALB integration
- Setting up CI/CD pipelines for Java Lambda
## Instructions
### 1. Choose Your Approach
| Approach | Cold Start | Best For | Complexity |
|----------|------------|----------|------------|
| Micronaut | < 1s | Complex apps, DI needed, enterprise | Medium |
| Raw Java | < 500ms | Simple handlers, minimal overhead | Low |
**Validate**: Confirm the approach fits your use case before proceeding.
### 2. Project Structure
```
my-lambda-function/
├── build.gradle (or pom.xml)
├── src/main/java/com/example/Handler.java
└── serverless.yml (or template.yaml)
```
**Validate**: Verify project structure matches the template.
### 3. Implementation Examples
#### Micronaut Handler
```java
@FunctionBean("my-function")
public class MyFunction implements Function<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private final MyService service;
public MyFunction(MyService service) {
this.service = service;
}
@Override
public APIGatewayProxyResponseEvent apply(APIGatewayProxyRequestEvent request) {
// Process request
return new APIGatewayProxyResponseEvent()
.withStatusCode(200)
.withBody("{\"message\": \"Success\"}");
}
}
```
#### Raw Java Handler
```java
public class MyHandler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private static final MyService service = new MyService();
@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent request, Context context) {
return new APIGatewayProxyResponseEvent()
.withStatusCode(200)
.withBody("{\"message\": \"Success\"}");
}
}
```
**Validate**: Run `sam local invoke` to verify handler works before deployment.
## Core Patterns
### Connection Management
```java
// Initialize once, reuse across invocations
private static final DynamoDbClient dynamoDb = DynamoDbClient.builder()
.region(Region.US_EAST_1)
.build();
// Avoid: Creating clients in handler (slow on every invocation)
```
### Error Handling
```java
@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent request, Context context) {
try {
return successResponse(process(request));
} catch (ValidationException e) {
return errorResponse(400, e.getMessage());
} catch (Exception e) {
context.getLogger().log("Error: " + e.getMessage());
return errorResponse(500, "Internal error");
}
}
```
## Best Practices
### Configuration
- **Memory**: Start with 512MB, adjust based on profiling
- **Timeout**: Micronaut 10-30s, Raw Java 5-10s
- **Runtime**: Java 17 or 21 for best performance
### Packaging
- Use Gradle Shadow Plugin or Maven Shade Plugin
- Exclude unnecessary dependencies
### Monitoring
- Enable X-Ray tracing for performance analysis
- Use CloudWatch Insights to track cold vs warm starts
## Deployment Options
### Serverless Framework
```yaml
service: my-java-lambda
provider:
name: aws
runtime: java21
memorySize: 512
timeout: 10
package:
artifact: build/libs/function.jar
functions:
api:
handler: com.example.Handler
events:
- http:
path: /{proxy+}
method: ANY
```
**Validate**: Run `serverless deploy` with `--stage dev` first.
### AWS SAM
```yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: build/libs/function.jar
Handler: com.example.Handler
Runtime: java21
MemorySize: 512
Timeout: 10
Events:
ApiEvent:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
```
**Validate**: Run `sam validate` before deploying.
## Constraints and Warnings
### Java-Specific Constraints
- **Reflection**: Minimize use; prefer AOT compilation (Micronaut)
- **Classpath scanning**: Slows cold start; use explicit configuration
- **Large frameworks**: Spring Boot adds significant cold start overhead
### Common Pitfalls
1. **Initialization in handler** - Causes repeated work on warm invocations
2. **Oversized JARs** - Include only required dependencies
3. **Insufficient memory** - Java needs more memory than Node.js/Python
4. **No timeout handling** - Always set appropriate timeouts
## References
For detailed guidance on specific topics:
- **[Micronaut Lambda](references/micronaut-lambda.md)** - Complete Micronaut setup, AOT configuration, DI optimization
- **[Raw Java Lambda](references/raw-java-lambda.md)** - Minimal handler patterns, singleton caching, JAR packaging
- **[Serverless Deployment](references/serverless-deployment.md)** - Serverless Framework, SAM, CI/CD pipelines, provisioned concurrency
- **[Testing Lambda](references/testing-lambda.md)** - JUnit 5, SAM Local, integration testing, performance measurement
## Examples
### Example 1: Create a Micronaut Lambda Function
**Input:**
```
Create a Java Lambda function using Micronaut to handle user REST API
```
**Process:**
1. Configure Gradle project with Micronaut plugin
2. Create Handler class extending MicronautRequestHandler
3. Implement methods for GET/POST/PUT/DELETE
4. Configure application.yml with AOT optimizations
5. Set up packaging with Shadow plugin
6. **Validate**: Test locally with SAM CLI before deploying
**Output:**
- Complete project structure
- Handler with dependency injection
- serverless.yml deployment configuration
### Example 2: Optimize Cold Start for Raw Java
**Input:**
```
My Java Lambda has 3 second cold start, how do I optimize it?
```
**Process:**
1. Analyze initialization code
2. Move AWS client creation to static fields
3. Reduce dependencies in build.gradle
4. Configure optimized JVM options
5. Consider provisioned concurrency
6. **Validate**: Measure cold start with CloudWatch metrics after changes
**Output:**
- Refactored code with singleton pattern
- Minimized JAR
- Cold start < 500ms
### Example 3: Deploy with GitHub Actions
**Input:**
```
Configure CI/CD for Java Lambda with SAM
```
**Process:**
1. Create GitHub Actions workflow
2. Configure Gradle build with Shadow
3. Set up SAM build and deploy
4. Add test stage before deployment
5. Configure environment protection for prod
**Output:**
- Complete .github/workflows/deploy.yml
- Multi-stage pipeline (dev/staging/prod)
- Integrated test automation
## Version
Version: 1.0.0
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.