Files
gh-giuseppe-trisciuoglio-de…/skills/aws-java/aws-sdk-java-v2-lambda/references/official-documentation.md
2025-11-29 18:28:30 +08:00

4.4 KiB

AWS Lambda Official Documentation Reference

Overview

AWS Lambda is a compute service that runs code without the need to manage servers. Your code runs automatically, scaling up and down with pay-per-use pricing.

Common Use Cases

  • Stream processing: Process real-time data streams for analytics
  • Web applications: Build scalable web apps that automatically adjust
  • Mobile backends: Create secure API backends
  • IoT backends: Handle web, mobile, IoT, and third-party API requests
  • File processing: Process files automatically when uploaded
  • Database operations: Respond to database changes and automate data workflows
  • Scheduled tasks: Run automated operations on a regular schedule

How Lambda Works

  1. You write and organize your code in Lambda functions
  2. You control security through Lambda permissions using execution roles
  3. Event sources and AWS services trigger your Lambda functions
  4. Lambda runs your code with language-specific runtimes

Key Features

Configuration & Security

  • Environment variables modify behavior without deployments
  • Versions safely test new features while maintaining stable production
  • Lambda layers optimize code reuse across multiple functions
  • Code signing ensures only approved code reaches production

Performance

  • Concurrency controls manage responsiveness and resource utilization
  • Lambda SnapStart reduces cold start times to sub-second performance
  • Response streaming delivers large payloads incrementally
  • Container images package functions with complex dependencies

Integration

  • VPC networks secure sensitive resources and internal services
  • File system integration shares persistent data across function invocations
  • Function URLs create public APIs without additional services
  • Lambda extensions augment functions with monitoring and operational tools

AWS Lambda Java SDK API

Key Classes

  • LambdaClient - Synchronous service client
  • LambdaAsyncClient - Asynchronous service client
  • LambdaClientBuilder - Builder for synchronous client
  • LambdaAsyncClientBuilder - Builder for asynchronous client
  • LambdaServiceClientConfiguration - Client settings configuration
  • software.amazon.awssdk.services.lambda.model - API models
  • software.amazon.awssdk.services.lambda.transform - Request/response transformations
  • software.amazon.awssdk.services.lambda.paginators - Pagination utilities
  • software.amazon.awssdk.services.lambda.waiters - Waiter utilities

Authentication

Lambda supports signature version 4 for API authentication.

CA Requirements

Clients need to support these CAs:

  • Amazon Root CA 1
  • Starfield Services Root Certificate Authority - G2
  • Starfield Class 2 Certification Authority

Core API Operations

Function Management Operations

  • CreateFunction - Create new Lambda function
  • DeleteFunction - Delete existing function
  • GetFunction - Retrieve function configuration
  • UpdateFunctionCode - Update function code
  • UpdateFunctionConfiguration - Update function settings
  • ListFunctions - List functions for account

Invocation Operations

  • Invoke - Invoke Lambda function synchronously
  • Invoke with InvocationType.EVENT - Asynchronous invocation

Environment & Configuration

  • Environment variable management
  • Function configuration updates
  • Version and alias management
  • Layer management

Examples Overview

The AWS documentation includes examples for:

  • Basic Lambda function creation and invocation
  • Function configuration and updates
  • Environment variable management
  • Function listing and cleanup
  • Integration patterns

Best Practices from Official Docs

  • Reuse Lambda clients across invocations
  • Set appropriate timeouts matching function requirements
  • Use async invocation for fire-and-forget scenarios
  • Implement proper error handling for function errors and status codes
  • Use environment variables for configuration management
  • Version functions for production stability
  • Monitor invocations using CloudWatch metrics
  • Implement retry logic for transient failures
  • Use VPC integration for private resources
  • Optimize payload sizes for performance

Security Considerations

  • Use IAM roles with least privilege
  • Implement proper Lambda permissions
  • Use environment variables for sensitive data
  • Enable CloudTrail logging
  • Monitor security events with CloudWatch
  • Use code signing for production deployments
  • Implement proper authentication and authorization