Class LambdaFunction

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.events.targets.LambdaFunction
All Implemented Interfaces:
IRuleTarget, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-06T23:25:10.351Z") @Stability(Stable) public class LambdaFunction extends software.amazon.jsii.JsiiObject implements IRuleTarget
Use an AWS Lambda function as an event rule target.

Example:

 import software.amazon.awscdk.services.lambda.*;
 Function fn = Function.Builder.create(this, "MyFunc")
         .runtime(Runtime.NODEJS_LATEST)
         .handler("index.handler")
         .code(Code.fromInline("exports.handler = handler.toString()"))
         .build();
 Rule rule = Rule.Builder.create(this, "rule")
         .eventPattern(EventPattern.builder()
                 .source(List.of("aws.ec2"))
                 .build())
         .build();
 Queue queue = new Queue(this, "Queue");
 rule.addTarget(LambdaFunction.Builder.create(fn)
         .deadLetterQueue(queue) // Optional: add a dead letter queue
         .maxEventAge(Duration.hours(2)) // Optional: set the maxEventAge retry policy
         .retryAttempts(2)
         .build());
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A fluent builder for LambdaFunction.

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.amazon.awscdk.services.events.IRuleTarget

    IRuleTarget.Jsii$Default, IRuleTarget.Jsii$Proxy
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
     
     
     
    protected
    LambdaFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    LambdaFunction(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    bind(IRule rule)
    Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event.
    bind(IRule rule, String _id)
    Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • LambdaFunction

      protected LambdaFunction(software.amazon.jsii.JsiiObjectRef objRef)
    • LambdaFunction

      protected LambdaFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • LambdaFunction

      @Stability(Stable) public LambdaFunction(@NotNull IFunction handler, @Nullable LambdaFunctionProps props)
      Parameters:
      handler - This parameter is required.
      props -
    • LambdaFunction

      @Stability(Stable) public LambdaFunction(@NotNull IFunction handler)
      Parameters:
      handler - This parameter is required.
  • Method Details

    • bind

      @Stability(Stable) @NotNull public RuleTargetConfig bind(@NotNull IRule rule, @Nullable String _id)
      Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event.

      Specified by:
      bind in interface IRuleTarget
      Parameters:
      rule - This parameter is required.
      _id -
    • bind

      @Stability(Stable) @NotNull public RuleTargetConfig bind(@NotNull IRule rule)
      Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event.

      Specified by:
      bind in interface IRuleTarget
      Parameters:
      rule - This parameter is required.