Skip to content
v2.278.0

LambdaFunctionProps Struct ​

Customize the Lambda Event Target.

Example ​

ts
declare const rule: events.Rule;
declare const fn: lambda.Function;

rule.addTarget(new targets.LambdaFunction(fn, {
  event: events.RuleTargetInput.fromObject({
    instance: events.EventField.fromPath('$.detail.instance-id'),
    account: events.EventField.account,
  }),
}));
python
# rule: events.Rule
# fn: lambda.Function


rule.add_target(targets.LambdaFunction(fn,
    event=events.RuleTargetInput.from_object({
        "instance": events.EventField.from_path("$.detail.instance-id"),
        "account": events.EventField.account
    })
))
java
Rule rule;
Function fn;


rule.addTarget(LambdaFunction.Builder.create(fn)
        .event(RuleTargetInput.fromObject(Map.of(
                "instance", EventField.fromPath("$.detail.instance-id"),
                "account", EventField.getAccount())))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Rule rule;
Function fn;


rule.AddTarget(new LambdaFunction(fn, new LambdaFunctionProps {
    Event = RuleTargetInput.FromObject(new Dictionary<string, string> {
        { "instance", EventField.FromPath("$.detail.instance-id") },
        { "account", EventField.Account }
    })
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var rule Rule
var fn Function


rule.AddTarget(targets.NewLambdaFunction(fn, &LambdaFunctionProps{
	Event: events.RuleTargetInput_FromObject(map[string]*string{
		"instance": events.EventField_fromPath(jsii.String("$.detail.instance-id")),
		"account": events.EventField_account(),
	}),
}))

Properties ​

deadLetterQueueoptionalIQueuedead_letter_queueoptionalIQueuedeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueue #
The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.

Default: no dead-letter queue

notes

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.

eventoptionalRuleTargetInputeventoptionalRuleTargetInputeventoptionalRuleTargetInputEventoptionalRuleTargetInputEventoptionalRuleTargetInput #
The event to send to the Lambda.

Default: the entire EventBridge event

This will be the payload sent to the Lambda Function.

maxEventAgeoptionalDurationmax_event_ageoptionalDurationmaxEventAgeoptionalDurationMaxEventAgeoptionalDurationMaxEventAgeoptionalDuration = Duration.hours(24) #
The maximum age of a request that Lambda sends to a function for processing.

Minimum value of 60. Maximum value of 86400.

retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64 = 185 #
The maximum number of times to retry when the function returns an error.

Minimum value of 0. Maximum value of 185.