putFunctionEventInvokeConfig method
- required String functionName,
- DestinationConfig? destinationConfig,
- int? maximumEventAgeInSeconds,
- int? maximumRetryAttempts,
- String? qualifier,
Configures options for asynchronous invocation on a function, version, or alias. If a configuration already exists for a function, version, or alias, this operation overwrites it. If you exclude any settings, they are removed. To set one option without affecting existing settings for other options, use UpdateFunctionEventInvokeConfig.
By default, Lambda retries an asynchronous invocation twice if the function returns an error. It retains events in a queue for up to six hours. When an event fails all processing attempts or stays in the asynchronous invocation queue for too long, Lambda discards it. To retain discarded events, configure a dead-letter queue with UpdateFunctionConfiguration.
To send an invocation record to a queue, topic, function, or event bus, specify a destination. You can configure separate destinations for successful invocations (on-success) and events that fail all processing attempts (on-failure). You can configure destinations in addition to or instead of a dead-letter queue.
May throw ServiceException. May throw ResourceNotFoundException. May throw InvalidParameterValueException. May throw TooManyRequestsException.
Parameter functionName
:
The name of the Lambda function, version, or alias.
Name formats
-
Function name -
my-function
(name-only),my-function:v1
(with alias). -
Function ARN -
arn:aws:lambda:us-west-2:123456789012:function:my-function
. -
Partial ARN -
123456789012:function:my-function
.
Parameter destinationConfig
:
A destination for events after they have been sent to a function for
processing.
Destinations
- Function - The Amazon Resource Name (ARN) of a Lambda function.
- Queue - The ARN of an SQS queue.
- Topic - The ARN of an SNS topic.
- Event Bus - The ARN of an Amazon EventBridge event bus.
Parameter maximumEventAgeInSeconds
:
The maximum age of a request that Lambda sends to a function for
processing.
Parameter maximumRetryAttempts
:
The maximum number of times to retry when the function returns an error.
Parameter qualifier
:
A version number or alias name.
Implementation
Future<FunctionEventInvokeConfig> putFunctionEventInvokeConfig({
required String functionName,
DestinationConfig? destinationConfig,
int? maximumEventAgeInSeconds,
int? maximumRetryAttempts,
String? qualifier,
}) async {
ArgumentError.checkNotNull(functionName, 'functionName');
_s.validateStringLength(
'functionName',
functionName,
1,
140,
isRequired: true,
);
_s.validateNumRange(
'maximumEventAgeInSeconds',
maximumEventAgeInSeconds,
60,
21600,
);
_s.validateNumRange(
'maximumRetryAttempts',
maximumRetryAttempts,
0,
2,
);
_s.validateStringLength(
'qualifier',
qualifier,
1,
128,
);
final $query = <String, List<String>>{
if (qualifier != null) 'Qualifier': [qualifier],
};
final $payload = <String, dynamic>{
if (destinationConfig != null) 'DestinationConfig': destinationConfig,
if (maximumEventAgeInSeconds != null)
'MaximumEventAgeInSeconds': maximumEventAgeInSeconds,
if (maximumRetryAttempts != null)
'MaximumRetryAttempts': maximumRetryAttempts,
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri:
'/2019-09-25/functions/${Uri.encodeComponent(functionName)}/event-invoke-config',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return FunctionEventInvokeConfig.fromJson(response);
}