CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-amazonaws--aws-java-sdk-lambda

AWS Java SDK client for communicating with AWS Lambda Service for function management, invocation, and resource control

Pending
Overview
Eval results
Files

event-source-mapping.mddocs/

Event Source Mapping

Management of event source mappings that connect Lambda functions to event sources like Amazon DynamoDB, Amazon Kinesis, Amazon SQS, Amazon MQ, Amazon MSK, Apache Kafka, and Amazon DocumentDB.

Capabilities

Event Source Mapping Creation

Creates mapping between event source and Lambda function.

/**
 * Creates event source mapping to connect Lambda function with event source
 * @param request Event source mapping configuration
 * @return CreateEventSourceMappingResult containing mapping details
 * @throws ResourceNotFoundException if function or event source doesn't exist
 * @throws InvalidParameterValueException if parameters are invalid
 * @throws ResourceConflictException if mapping already exists
 * @throws TooManyRequestsException if concurrent requests exceed limits
 */
CreateEventSourceMappingResult createEventSourceMapping(CreateEventSourceMappingRequest request);

public class CreateEventSourceMappingRequest {
    /** Event source ARN (required for most sources) */
    private String eventSourceArn;
    /** Function name, ARN, or qualified ARN (required) */
    private String functionName;
    /** Whether mapping is enabled (optional, default: true) */
    private Boolean enabled;
    /** Batch size for records (optional, varies by source) */
    private Integer batchSize;
    /** Maximum batching window in seconds (optional) */
    private Integer maximumBatchingWindowInSeconds;
    /** Parallelization factor for Kinesis/DynamoDB (optional, range: 1-10) */
    private Integer parallelizationFactor;
    /** Starting position for Kinesis/DynamoDB (optional) */
    private EventSourcePosition startingPosition;
    /** Starting position timestamp for AT_TIMESTAMP (optional) */
    private java.util.Date startingPositionTimestamp;
    /** Destination configuration for failures (optional) */
    private DestinationConfig destinationConfig;
    /** Maximum record age in seconds (optional) */
    private Integer maximumRecordAgeInSeconds;
    /** Whether to split batch on error (optional) */
    private Boolean bisectBatchOnFunctionError;
    /** Maximum retry attempts (optional) */
    private Integer maximumRetryAttempts;
    /** Tumbling window in seconds (optional) */
    private Integer tumblingWindowInSeconds;
    /** Topic names for Kafka/MSK (optional) */
    private List<String> topics;
    /** Queue configurations for SQS (optional) */
    private List<String> queues;
    /** Source access configurations (optional) */
    private List<SourceAccessConfiguration> sourceAccessConfigurations;
    /** Self-managed event source config (optional) */
    private SelfManagedEventSource selfManagedEventSource;
    /** Function response types (optional) */
    private List<String> functionResponseTypes;
    /** Amazon managed Kafka event source config (optional) */
    private AmazonManagedKafkaEventSourceConfig amazonManagedKafkaEventSourceConfig;
    /** Self-managed Kafka event source config (optional) */
    private SelfManagedKafkaEventSourceConfig selfManagedKafkaEventSourceConfig;
    /** Scaling configuration (optional) */
    private ScalingConfig scalingConfig;
    /** DocumentDB event source config (optional) */
    private DocumentDBEventSourceConfig documentDBEventSourceConfig;
    
    // Fluent setters
    public CreateEventSourceMappingRequest withEventSourceArn(String eventSourceArn) { ... }
    public CreateEventSourceMappingRequest withFunctionName(String functionName) { ... }
    // ... other fluent setters
}

public class CreateEventSourceMappingResult {
    /** Event source mapping UUID */
    private String uuid;
    /** Batch size */
    private Integer batchSize;
    /** Maximum batching window in seconds */
    private Integer maximumBatchingWindowInSeconds;
    /** Parallelization factor */
    private Integer parallelizationFactor;
    /** Event source ARN */
    private String eventSourceArn;
    /** Function ARN */
    private String functionArn;
    /** Last modified timestamp */
    private java.util.Date lastModified;
    /** Last processing result */
    private String lastProcessingResult;
    /** State of the mapping */
    private String state;
    /** State transition reason */
    private String stateTransitionReason;
    /** Destination configuration */
    private DestinationConfig destinationConfig;
    /** Topic names */
    private List<String> topics;
    /** Queue configurations */
    private List<String> queues;
    /** Source access configurations */
    private List<SourceAccessConfiguration> sourceAccessConfigurations;
    /** Self-managed event source config */
    private SelfManagedEventSource selfManagedEventSource;
    /** Maximum record age in seconds */
    private Integer maximumRecordAgeInSeconds;
    /** Whether to split batch on error */
    private Boolean bisectBatchOnFunctionError;
    /** Maximum retry attempts */
    private Integer maximumRetryAttempts;
    /** Tumbling window in seconds */
    private Integer tumblingWindowInSeconds;
    /** Function response types */
    private List<String> functionResponseTypes;
    // ... other fields
}

Event Source Mapping Operations

/**
 * Gets event source mapping details
 * @param request Mapping retrieval parameters
 * @return GetEventSourceMappingResult containing mapping configuration
 */
GetEventSourceMappingResult getEventSourceMapping(GetEventSourceMappingRequest request);

/**
 * Updates existing event source mapping
 * @param request Mapping update parameters
 * @return UpdateEventSourceMappingResult with updated configuration
 */
UpdateEventSourceMappingResult updateEventSourceMapping(UpdateEventSourceMappingRequest request);

/**
 * Deletes event source mapping
 * @param request Mapping deletion parameters
 * @return DeleteEventSourceMappingResult with final mapping state
 */
DeleteEventSourceMappingResult deleteEventSourceMapping(DeleteEventSourceMappingRequest request);

/**
 * Lists event source mappings with optional filtering
 * @param request Listing parameters
 * @return ListEventSourceMappingsResult containing mappings and pagination
 */
ListEventSourceMappingsResult listEventSourceMappings(ListEventSourceMappingsRequest request);

/**
 * Lists all event source mappings
 * @return ListEventSourceMappingsResult containing all mappings
 */
ListEventSourceMappingsResult listEventSourceMappings();

Supporting Types

/** Event source starting position */
public enum EventSourcePosition {
    TRIM_HORIZON,  // Start from oldest record
    LATEST,        // Start from newest record  
    AT_TIMESTAMP   // Start from specific timestamp
}

/** Source access configuration for authentication */
public class SourceAccessConfiguration {
    /** Configuration type */
    private SourceAccessType type;
    /** Configuration URI */
    private String uri;
    
    public SourceAccessConfiguration withType(SourceAccessType type) { ... }
    public SourceAccessConfiguration withUri(String uri) { ... }
}

public enum SourceAccessType {
    BASIC_AUTH,           // Basic authentication
    VPC_SUBNET,           // VPC subnet ID
    VPC_SECURITY_GROUP,   // VPC security group ID
    SASL_SCRAM_512_AUTH,  // SASL/SCRAM authentication
    SASL_SCRAM_256_AUTH,  // SASL/SCRAM authentication
    VIRTUAL_HOST,         // Virtual host
    CLIENT_CERTIFICATE_TLS_AUTH  // TLS client certificate
}

/** Destination configuration for failed records */
public class DestinationConfig {
    /** Success destination */
    private OnSuccess onSuccess;
    /** Failure destination */
    private OnFailure onFailure;
    
    public DestinationConfig withOnSuccess(OnSuccess onSuccess) { ... }
    public DestinationConfig withOnFailure(OnFailure onFailure) { ... }
}

public class OnFailure {
    /** Destination ARN (SQS queue or SNS topic) */
    private String destination;
    
    public OnFailure withDestination(String destination) { ... }
}

public class OnSuccess {
    /** Destination ARN */
    private String destination;
    
    public OnSuccess withDestination(String destination) { ... }
}

Usage Examples:

import com.amazonaws.services.lambda.*;
import com.amazonaws.services.lambda.model.*;

AWSLambda lambdaClient = AWSLambdaClientBuilder.defaultClient();

// Create DynamoDB event source mapping
CreateEventSourceMappingRequest dynamoRequest = new CreateEventSourceMappingRequest()
    .withEventSourceArn("arn:aws:dynamodb:us-east-1:123456789012:table/MyTable/stream/2024-01-01T00:00:00.000")
    .withFunctionName("my-dynamo-processor")
    .withStartingPosition(EventSourcePosition.TRIM_HORIZON)
    .withBatchSize(10)
    .withMaximumBatchingWindowInSeconds(5)
    .withParallelizationFactor(2)
    .withMaximumRecordAgeInSeconds(3600)
    .withBisectBatchOnFunctionError(true)
    .withMaximumRetryAttempts(3)
    .withDestinationConfig(new DestinationConfig()
        .withOnFailure(new OnFailure()
            .withDestination("arn:aws:sqs:us-east-1:123456789012:failed-records")));

CreateEventSourceMappingResult dynamoResult = lambdaClient.createEventSourceMapping(dynamoRequest);
System.out.println("Created DynamoDB mapping: " + dynamoResult.getUuid());

// Create SQS event source mapping
CreateEventSourceMappingRequest sqsRequest = new CreateEventSourceMappingRequest()
    .withEventSourceArn("arn:aws:sqs:us-east-1:123456789012:my-queue")
    .withFunctionName("my-sqs-processor")
    .withBatchSize(5)
    .withMaximumBatchingWindowInSeconds(10);

CreateEventSourceMappingResult sqsResult = lambdaClient.createEventSourceMapping(sqsRequest);

// Create MSK (Kafka) event source mapping
CreateEventSourceMappingRequest mskRequest = new CreateEventSourceMappingRequest()
    .withEventSourceArn("arn:aws:kafka:us-east-1:123456789012:cluster/my-cluster/uuid")
    .withFunctionName("my-kafka-processor")
    .withTopics(Arrays.asList("orders", "payments"))
    .withBatchSize(100)
    .withStartingPosition(EventSourcePosition.LATEST)
    .withSourceAccessConfigurations(Arrays.asList(
        new SourceAccessConfiguration()
            .withType(SourceAccessType.VPC_SUBNET)
            .withUri("subnet-12345678"),
        new SourceAccessConfiguration()
            .withType(SourceAccessType.VPC_SECURITY_GROUP)
            .withUri("sg-87654321")
    ));

CreateEventSourceMappingResult mskResult = lambdaClient.createEventSourceMapping(mskRequest);

// Update event source mapping
UpdateEventSourceMappingRequest updateRequest = new UpdateEventSourceMappingRequest()
    .withUuid(dynamoResult.getUuid())
    .withBatchSize(20)
    .withMaximumBatchingWindowInSeconds(10)
    .withEnabled(true);

UpdateEventSourceMappingResult updateResult = lambdaClient.updateEventSourceMapping(updateRequest);

// List event source mappings for function
ListEventSourceMappingsRequest listRequest = new ListEventSourceMappingsRequest()
    .withFunctionName("my-dynamo-processor");

ListEventSourceMappingsResult listResult = lambdaClient.listEventSourceMappings(listRequest);
for (EventSourceMappingConfiguration mapping : listResult.getEventSourceMappings()) {
    System.out.println("Mapping: " + mapping.getUuid() + 
                      " - State: " + mapping.getState() +
                      " - Source: " + mapping.getEventSourceArn());
}

// Get specific mapping details
GetEventSourceMappingRequest getRequest = new GetEventSourceMappingRequest()
    .withUuid(dynamoResult.getUuid());

GetEventSourceMappingResult getResult = lambdaClient.getEventSourceMapping(getRequest);
System.out.println("Mapping state: " + getResult.getState());
System.out.println("Last processing result: " + getResult.getLastProcessingResult());

// Delete event source mapping
DeleteEventSourceMappingRequest deleteRequest = new DeleteEventSourceMappingRequest()
    .withUuid(dynamoResult.getUuid());

DeleteEventSourceMappingResult deleteResult = lambdaClient.deleteEventSourceMapping(deleteRequest);
System.out.println("Deleted mapping, final state: " + deleteResult.getState());

Install with Tessl CLI

npx tessl i tessl/maven-com-amazonaws--aws-java-sdk-lambda

docs

account-settings.md

alias-version-management.md

client-management.md

concurrency-performance.md

event-source-mapping.md

function-invocation.md

function-management.md

function-url-management.md

high-level-invocation.md

index.md

layer-management.md

permissions-policies.md

runtime-management.md

security-code-signing.md

tagging.md

waiters-polling.md

tile.json