Class LambdaFunction
Use an AWS Lambda function as an event rule target.
Inheritance
System.Object
LambdaFunction
Implements
Namespace: Amazon.CDK.AWS.Events.Targets
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LambdaFunction : DeputyBase, IRuleTarget
Syntax (vb)
Public Class LambdaFunction
Inherits DeputyBase
Implements IRuleTarget
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
LambdaFunction(IFunction, ILambdaFunctionProps) | |
LambdaFunction(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
LambdaFunction(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
Bind(IRule, String) | Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event. |
Constructors
LambdaFunction(IFunction, ILambdaFunctionProps)
public LambdaFunction(IFunction handler, ILambdaFunctionProps props = null)
Parameters
- handler IFunction
- props ILambdaFunctionProps
LambdaFunction(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected LambdaFunction(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
LambdaFunction(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected LambdaFunction(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
Bind(IRule, String)
Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event.
public virtual IRuleTargetConfig Bind(IRule rule, string id = null)
Parameters
- rule IRule
- id System.String
Returns