EventBridge duplicate events breaking idempotency

The Genesys Cloud EventBridge integration is firing duplicate events for the same contact-update action. Terraform state is clean, provider is v1.72.0. The issue isn’t the infrastructure, it’s the payload handling in the consumer lambda. I’m seeing two identical JSON payloads arrive within 200ms. The event.id is the same, but the detail-type triggers a second execution before the first one finishes.

Here’s the event snippet:

{
 "id": "abc-123-def",
 "detail-type": "contact-update",
 "detail": {
 "interactionId": "xyz-789",
 "state": "connected"
 }
}

The lambda checks for a lock in DynamoDB using interactionId. First call gets the lock, updates DB, releases lock. Second call arrives while first is still running? No, the second call sees the lock exists and skips. But sometimes the second call arrives after the first releases the lock but before the DB write is fully committed or visible? Or is it a retry from EventBridge itself?

I’ve added a dedup key in the EventBridge rule, but it’s not working. The docs say EventBridge doesn’t guarantee exactly-once delivery for Genesys sources. So I need a code-level fix.

Is there a unique timestamp or sequence number in the Genesys payload I can use for deduplication instead of just interactionId? The time field is identical in both events. I’m stuck. The lambda logs show:

[INFO] Processing event abc-123-def
[INFO] Lock acquired for xyz-789
[INFO] DB write complete
[INFO] Lock released
[INFO] Processing event abc-123-def
[INFO] Lock acquired for xyz-789
[INFO] DB write complete
[INFO] Lock released

Both events process. This breaks my analytics. How do I filter the second event? I’ve tried checking the event.source but it’s the same. The Terraform config for the EventBridge target is standard. Nothing fancy. Just a lambda ARN. I need a way to reject the duplicate in the lambda code. Any ideas?