updateEventSourceMapping method

Future<EventSourceMappingConfiguration> updateEventSourceMapping({
  1. required String uuid,
  2. int? batchSize,
  3. bool? bisectBatchOnFunctionError,
  4. DestinationConfig? destinationConfig,
  5. bool? enabled,
  6. String? functionName,
  7. List<FunctionResponseType>? functionResponseTypes,
  8. int? maximumBatchingWindowInSeconds,
  9. int? maximumRecordAgeInSeconds,
  10. int? maximumRetryAttempts,
  11. int? parallelizationFactor,
  12. List<SourceAccessConfiguration>? sourceAccessConfigurations,
  13. int? tumblingWindowInSeconds,
})

Updates an event source mapping. You can change the function that AWS Lambda invokes, or pause invocation and resume later from the same location.

The following error handling options are only available for stream sources (DynamoDB and Kinesis):

  • BisectBatchOnFunctionError - If the function returns an error, split the batch in two and retry.
  • DestinationConfig - Send discarded records to an Amazon SQS queue or Amazon SNS topic.
  • MaximumRecordAgeInSeconds - Discard records older than the specified age. The default value is infinite (-1). When set to infinite (-1), failed records are retried until the record expires
  • MaximumRetryAttempts - Discard records after the specified number of retries. The default value is infinite (-1). When set to infinite (-1), failed records are retried until the record expires.
  • ParallelizationFactor - Process multiple batches from each shard concurrently.

May throw ServiceException. May throw ResourceNotFoundException. May throw InvalidParameterValueException. May throw TooManyRequestsException. May throw ResourceConflictException. May throw ResourceInUseException.

Parameter uuid : The identifier of the event source mapping.

Parameter batchSize : The maximum number of items to retrieve in a single batch.

  • Amazon Kinesis - Default 100. Max 10,000.
  • Amazon DynamoDB Streams - Default 100. Max 1,000.
  • Amazon Simple Queue Service - Default 10. For standard queues the max is 10,000. For FIFO queues the max is 10.
  • Amazon Managed Streaming for Apache Kafka - Default 100. Max 10,000.
  • Self-Managed Apache Kafka - Default 100. Max 10,000.

Parameter bisectBatchOnFunctionError : (Streams) If the function returns an error, split the batch in two and retry.

Parameter destinationConfig : (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.

Parameter enabled : If true, the event source mapping is active. Set to false to pause polling and invocation.

Parameter functionName : The name of the Lambda function.

Name formats

  • Function name - MyFunction.
  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.
  • Version or Alias ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.
  • Partial ARN - 123456789012:function:MyFunction.
The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.

Parameter functionResponseTypes : (Streams) A list of current response type enums applied to the event source mapping.

Parameter maximumBatchingWindowInSeconds : (Streams and SQS standard queues) The maximum amount of time to gather records before invoking the function, in seconds.

Parameter maximumRecordAgeInSeconds : (Streams) Discard records older than the specified age. The default value is infinite (-1).

Parameter maximumRetryAttempts : (Streams) Discard records after the specified number of retries. The default value is infinite (-1). When set to infinite (-1), failed records will be retried until the record expires.

Parameter parallelizationFactor : (Streams) The number of batches to process from each shard concurrently.

Parameter sourceAccessConfigurations : An array of the authentication protocol, or the VPC components to secure your event source.

Parameter tumblingWindowInSeconds : (Streams) The duration of a processing window in seconds. The range is between 1 second up to 15 minutes.

Implementation

Future<EventSourceMappingConfiguration> updateEventSourceMapping({
  required String uuid,
  int? batchSize,
  bool? bisectBatchOnFunctionError,
  DestinationConfig? destinationConfig,
  bool? enabled,
  String? functionName,
  List<FunctionResponseType>? functionResponseTypes,
  int? maximumBatchingWindowInSeconds,
  int? maximumRecordAgeInSeconds,
  int? maximumRetryAttempts,
  int? parallelizationFactor,
  List<SourceAccessConfiguration>? sourceAccessConfigurations,
  int? tumblingWindowInSeconds,
}) async {
  ArgumentError.checkNotNull(uuid, 'uuid');
  _s.validateNumRange(
    'batchSize',
    batchSize,
    1,
    10000,
  );
  _s.validateStringLength(
    'functionName',
    functionName,
    1,
    140,
  );
  _s.validateNumRange(
    'maximumBatchingWindowInSeconds',
    maximumBatchingWindowInSeconds,
    0,
    300,
  );
  _s.validateNumRange(
    'maximumRecordAgeInSeconds',
    maximumRecordAgeInSeconds,
    -1,
    604800,
  );
  _s.validateNumRange(
    'maximumRetryAttempts',
    maximumRetryAttempts,
    -1,
    10000,
  );
  _s.validateNumRange(
    'parallelizationFactor',
    parallelizationFactor,
    1,
    10,
  );
  _s.validateNumRange(
    'tumblingWindowInSeconds',
    tumblingWindowInSeconds,
    0,
    900,
  );
  final $payload = <String, dynamic>{
    if (batchSize != null) 'BatchSize': batchSize,
    if (bisectBatchOnFunctionError != null)
      'BisectBatchOnFunctionError': bisectBatchOnFunctionError,
    if (destinationConfig != null) 'DestinationConfig': destinationConfig,
    if (enabled != null) 'Enabled': enabled,
    if (functionName != null) 'FunctionName': functionName,
    if (functionResponseTypes != null)
      'FunctionResponseTypes':
          functionResponseTypes.map((e) => e.toValue()).toList(),
    if (maximumBatchingWindowInSeconds != null)
      'MaximumBatchingWindowInSeconds': maximumBatchingWindowInSeconds,
    if (maximumRecordAgeInSeconds != null)
      'MaximumRecordAgeInSeconds': maximumRecordAgeInSeconds,
    if (maximumRetryAttempts != null)
      'MaximumRetryAttempts': maximumRetryAttempts,
    if (parallelizationFactor != null)
      'ParallelizationFactor': parallelizationFactor,
    if (sourceAccessConfigurations != null)
      'SourceAccessConfigurations': sourceAccessConfigurations,
    if (tumblingWindowInSeconds != null)
      'TumblingWindowInSeconds': tumblingWindowInSeconds,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/2015-03-31/event-source-mappings/${Uri.encodeComponent(uuid)}',
    exceptionFnMap: _exceptionFns,
  );
  return EventSourceMappingConfiguration.fromJson(response);
}