Provision event buses and rules, route matching events to standard SQS queues, and publish JSON event fixtures. Task types live in io.github.gregwhitaker.awsemulator.aws.eventbridge.
Provision Before Tests
import io.github.gregwhitaker.awsemulator.aws.eventbridge.*
import io.github.gregwhitaker.awsemulator.aws.sqs.CreateSqsQueueTask
plugins {
java
id("io.github.gregwhitaker.aws-emulator") version "0.3.0"
}
val bus = tasks.register<CreateEventBusTask>("createOrdersBus") {
eventBusName.set("application-orders")
}
val rule = tasks.register<PutEventBridgeRuleTask>("createOrdersRule") {
dependsOn(bus)
eventBusName.set("application-orders")
ruleName.set("orders")
eventPattern.set("""{"source":["app.orders"]}""")
}
val queue = tasks.register<CreateSqsQueueTask>("createEventQueue") {
queueName.set("application-events")
}
val target = tasks.register<PutEventBridgeSqsTargetTask>("connectEventQueue") {
dependsOn(rule, queue)
eventBusName.set("application-orders")
ruleName.set("orders")
queueName.set("application-events")
targetId.set("orders-queue")
}
val events = tasks.register<PublishEventBridgeEventsTask>("publishTestEvents") {
dependsOn(target)
eventBusName.set("application-orders")
fixtures.set(layout.projectDirectory.file("fixtures/events.json"))
}
val tests = tasks.named<Test>("test") { dependsOn(events) }
awsEmulator { useWith(tests) }
The target task configures delivery to the queue. See the SQS guide for queue settings and message fixtures.
Task Properties
| Task type | Configuration |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
Lists buses and ARNs |
|
|
|
|
|
|
Event Fixtures
[
{"source":"app.orders","detailType":"OrderCreated","detail":{"id":"order-1"}}
]
source and detailType are nonblank strings; detail must be a JSON object. This release uses a conservative 256 KiB entry/request limit and batches up to ten events. It verifies bus existence before publishing. Partial batch failures identify one-based fixture indexes; successful events are retained and are not automatically replayed. Rerunning a publisher can duplicate events.
Targets And Repeated Setup
Target IDs make repeated setup stable. Existing conflicting targets/rules require overwrite=true; unrelated target IDs are preserved. The SQS convenience task preserves unrelated queue-policy statements and adds one rule-scoped grant. Deleting a rule leaves that grant in the queue policy; it does not delete the queue. FIFO targets, schedules, SNS targets, input transformations, and replay/archive management are not part of this initial task scope.
Cleanup And Development Commands
Declare cleanup ordering explicitly when deleting dependent resources in one build. Configuration-cache execution can run independent tasks concurrently: use tasks.named("deleteEventBus") { mustRunAfter("deleteEventBridgeRule") } when both commands are selected. The runnable example configures this ordering.
Predefined commands: listEventBuses, listEventBridgeRules, deleteEventBridgeRule, and deleteEventBus. Rule commands accept --eventBusName and --ruleName as applicable. The default event bus cannot be deleted.
./gradlew listEventBuses
./gradlew listEventBridgeRules --eventBusName=application-orders
./gradlew deleteEventBridgeRule --eventBusName=application-orders --ruleName=orders
./gradlew deleteEventBus --eventBusName=application-orders
Runtime Selection
Custom resource tasks inherit awsEmulator.defaultMode, initially MANAGED. Make the consuming test or application task depend on provisioning and opt that consumer in with awsEmulator.useWith(…). Provisioning and consumers must select the same runtime name and mode; see resource task defaults to configure a shared development default.
Every task accepts runtimeName (default default), mode, and apiCallTimeoutSeconds (default 30, positive). Predefined inspection and deletion commands default to DEVELOPMENT; select another mode with --mode=MANAGED or another declared runtime with --runtime <name>. For persistent setup, see development resource tasks.
Resource tasks always execute against live emulator state and do not use the build cache. Configuration-cache reuse is supported. Applying the plugin and listing tasks do not start Docker. Task input values may be stored in Gradle’s configuration cache; fixtures should contain local test values.
Runnable Example
./gradlew -p examples/services verifyServices --configuration-cache
The example routes a matching EventBridge event to a standard SQS queue and verifies delivery with AWS SDK for Java v2. Run the command twice to check configuration-cache reuse against a fresh managed emulator. -PfailExample=true deliberately fails the application test to demonstrate cleanup. See the runnable example for its complete setup and persistent development commands.
Verified Scope
The examples exercise these workflows against the pinned AWS Emulator 1.0.385, using AWS SDK for Java v2 2.39.6. They establish the behavior used by these tasks, not complete AWS service equivalence. AWS Emulator fidelity varies by operation and release.