Class LambdaFunctionProps
Customize the Lambda Event Target.
Inherited Members
Namespace: Amazon.CDK.AWS.Events.Targets
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LambdaFunctionProps : ILambdaFunctionProps, ITargetBaseProps
Syntax (vb)
Public Class LambdaFunctionProps Implements ILambdaFunctionProps, ITargetBaseProps
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.Lambda;
var fn = new Function(this, "MyFunc", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromInline("exports.handler = handler.toString()")
});
var rule = new Rule(this, "rule", new RuleProps {
EventPattern = new EventPattern {
Source = new [] { "aws.ec2" }
}
});
var queue = new Queue(this, "Queue");
rule.AddTarget(new LambdaFunction(fn, new LambdaFunctionProps {
DeadLetterQueue = queue, // Optional: add a dead letter queue
MaxEventAge = Duration.Hours(2), // Optional: set the maxEventAge retry policy
RetryAttempts = 2
}));
Synopsis
Constructors
| LambdaFunctionProps() | Customize the Lambda Event Target. |
Properties
| DeadLetterQueue | The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue. |
| Event | The event to send to the Lambda. |
| MaxEventAge | The maximum age of a request that Lambda sends to a function for processing. |
| RetryAttempts | The maximum number of times to retry when the function returns an error. |
Constructors
LambdaFunctionProps()
Customize the Lambda Event Target.
public LambdaFunctionProps()
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.Lambda;
var fn = new Function(this, "MyFunc", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromInline("exports.handler = handler.toString()")
});
var rule = new Rule(this, "rule", new RuleProps {
EventPattern = new EventPattern {
Source = new [] { "aws.ec2" }
}
});
var queue = new Queue(this, "Queue");
rule.AddTarget(new LambdaFunction(fn, new LambdaFunctionProps {
DeadLetterQueue = queue, // Optional: add a dead letter queue
MaxEventAge = Duration.Hours(2), // Optional: set the maxEventAge retry policy
RetryAttempts = 2
}));
Properties
DeadLetterQueue
The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.
public IQueue? DeadLetterQueue { get; set; }
Property Value
Remarks
The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.
Default: - no dead-letter queue
Event
The event to send to the Lambda.
public RuleTargetInput? Event { get; set; }
Property Value
Remarks
This will be the payload sent to the Lambda Function.
Default: the entire EventBridge event
MaxEventAge
The maximum age of a request that Lambda sends to a function for processing.
public Duration? MaxEventAge { get; set; }
Property Value
Remarks
Minimum value of 60. Maximum value of 86400.
Default: Duration.hours(24)
RetryAttempts
The maximum number of times to retry when the function returns an error.
public double? RetryAttempts { get; set; }
Property Value
Remarks
Minimum value of 0. Maximum value of 185.
Default: 185