Skip to content
v2.278.0

EventBridgePutEventsEntry Struct ​

An entry to be sent to EventBridge.

Example ​

ts
import * as events from 'aws-cdk-lib/aws-events';

const eventBus = new events.EventBus(this, 'EventBus', {
  eventBusName: 'DomainEvents',
});

const eventEntry: targets.EventBridgePutEventsEntry = {
  eventBus,
  source: 'PetService',
  detail: ScheduleTargetInput.fromObject({ Name: 'Fluffy' }),
  detailType: '🐶',
};

new Schedule(this, 'Schedule', {
  schedule: ScheduleExpression.rate(Duration.hours(1)),
  target: new targets.EventBridgePutEvents(eventEntry),
});
python
import aws_cdk.aws_events as events


event_bus = events.EventBus(self, "EventBus",
    event_bus_name="DomainEvents"
)

event_entry = targets.EventBridgePutEventsEntry(
    event_bus=event_bus,
    source="PetService",
    detail=ScheduleTargetInput.from_object({"Name": "Fluffy"}),
    detail_type="🐶"
)

Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.hours(1)),
    target=targets.EventBridgePutEvents(event_entry)
)
java
import software.amazon.awscdk.services.events.*;


EventBus eventBus = EventBus.Builder.create(this, "EventBus")
        .eventBusName("DomainEvents")
        .build();

EventBridgePutEventsEntry eventEntry = EventBridgePutEventsEntry.builder()
        .eventBus(eventBus)
        .source("PetService")
        .detail(ScheduleTargetInput.fromObject(Map.of("Name", "Fluffy")))
        .detailType("🐶")
        .build();

Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.hours(1)))
        .target(new EventBridgePutEvents(eventEntry))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Events;


var eventBus = new EventBus(this, "EventBus", new EventBusProps {
    EventBusName = "DomainEvents"
});

var eventEntry = new EventBridgePutEventsEntry {
    EventBus = eventBus,
    Source = "PetService",
    Detail = ScheduleTargetInput.FromObject(new Dictionary<string, string> { { "Name", "Fluffy" } }),
    DetailType = "🐶"
};

new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Hours(1)),
    Target = new EventBridgePutEvents(eventEntry)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import events "github.com/aws/aws-cdk-go/awscdk"


eventBus := events.NewEventBus(this, jsii.String("EventBus"), &EventBusProps{
	EventBusName: jsii.String("DomainEvents"),
})

eventEntry := &EventBridgePutEventsEntry{
	EventBus: EventBus,
	Source: jsii.String("PetService"),
	Detail: awscdk.ScheduleTargetInput_FromObject(map[string]*string{
		"Name": jsii.String("Fluffy"),
	}),
	DetailType: jsii.String("🐶"),
}

awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Hours(jsii.Number(1))),
	Target: targets.NewEventBridgePutEvents(eventEntry),
})

Properties ​

The event body.

Can either be provided as an object or as a JSON-serialized string

example
ts
ScheduleTargetInput.fromText('{"instance-id": "i-1234567890abcdef0", "state": "terminated"}');
ScheduleTargetInput.fromObject({ Message: 'Hello from a friendly event :)' });
detailTypestringdetail_typestrdetailTypeStringDetailTypestringDetailType*string required #
Used along with the source field to help identify the fields and values expected in the detail field.

For example, events by CloudTrail have detail type "AWS API Call via CloudTrail"

eventBusIEventBusevent_busIEventBuseventBusIEventBusEventBusIEventBusEventBusIEventBus required #
The event bus the entry will be sent to.
sourcestringsourcestrsourceStringSourcestringSource*string required #
The service or application that caused this event to be generated.

Example value: com.example.service