Skip to content

Commit ef36fcc

Browse files
committed
update docs
1 parent 9d05ee8 commit ef36fcc

File tree

1 file changed

+105
-1
lines changed

1 file changed

+105
-1
lines changed

docs/core/event_handler/appsync_events.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,15 @@ When processing batch of items with `OnPublishAggregate()` and `OnPublishAggrega
445445
}
446446
```
447447

448-
#### Rejecting the entire request
448+
#### Authorization control
449449

450450
??? warning "Raising `UnauthorizedException` will cause the Lambda invocation to fail."
451451

452452
You can also reject the entire payload by raising an `UnauthorizedException`. This prevents Powertools for AWS from processing any messages and causes the Lambda invocation to fail, returning an error to AppSync.
453453

454+
- **When working with publish events** Powertools for AWS will stop processing messages and subscribers will not receive any message.
455+
- **When working with subscribe events** the subscription won't be established.
456+
454457
=== "Rejecting the entire request"
455458

456459
```csharp
@@ -474,6 +477,107 @@ You can access to the original Lambda event or context for additional informatio
474477
});
475478
```
476479

480+
## Event Handler workflow
481+
482+
#### Working with single items
483+
484+
<center>
485+
```mermaid
486+
sequenceDiagram
487+
participant Client
488+
participant AppSync
489+
participant Lambda
490+
participant EventHandler
491+
note over Client,EventHandler: Individual Event Processing (aggregate=False)
492+
Client->>+AppSync: Send multiple events to channel
493+
AppSync->>+Lambda: Invoke Lambda with batch of events
494+
Lambda->>+EventHandler: Process events with aggregate=False
495+
loop For each event in batch
496+
EventHandler->>EventHandler: Process individual event
497+
end
498+
EventHandler-->>-Lambda: Return array of processed events
499+
Lambda-->>-AppSync: Return event-by-event responses
500+
AppSync-->>-Client: Report individual event statuses
501+
```
502+
</center>
503+
504+
505+
#### Working with aggregated items
506+
507+
<center>
508+
```mermaid
509+
sequenceDiagram
510+
participant Client
511+
participant AppSync
512+
participant Lambda
513+
participant EventHandler
514+
note over Client,EventHandler: Aggregate Processing Workflow
515+
Client->>+AppSync: Send multiple events to channel
516+
AppSync->>+Lambda: Invoke Lambda with batch of events
517+
Lambda->>+EventHandler: Process events with aggregate=True
518+
EventHandler->>EventHandler: Batch of events
519+
EventHandler->>EventHandler: Process entire batch at once
520+
EventHandler->>EventHandler: Format response for each event
521+
EventHandler-->>-Lambda: Return aggregated results
522+
Lambda-->>-AppSync: Return success responses
523+
AppSync-->>-Client: Confirm all events processed
524+
```
525+
</center>
526+
527+
#### Authorization fails for publish
528+
529+
<center>
530+
```mermaid
531+
sequenceDiagram
532+
participant Client
533+
participant AppSync
534+
participant Lambda
535+
participant EventHandler
536+
note over Client,EventHandler: Publish Event Authorization Flow
537+
Client->>AppSync: Publish message to channel
538+
AppSync->>Lambda: Invoke Lambda with publish event
539+
Lambda->>EventHandler: Process publish event
540+
alt Authorization Failed
541+
EventHandler->>EventHandler: Authorization check fails
542+
EventHandler->>Lambda: Raise UnauthorizedException
543+
Lambda->>AppSync: Return error response
544+
AppSync--xClient: Message not delivered
545+
AppSync--xAppSync: No distribution to subscribers
546+
else Authorization Passed
547+
EventHandler->>Lambda: Return successful response
548+
Lambda->>AppSync: Return processed event
549+
AppSync->>Client: Acknowledge message
550+
AppSync->>AppSync: Distribute to subscribers
551+
end
552+
```
553+
</center>
554+
555+
#### Authorization fails for subscribe
556+
557+
<center>
558+
```mermaid
559+
sequenceDiagram
560+
participant Client
561+
participant AppSync
562+
participant Lambda
563+
participant EventHandler
564+
note over Client,EventHandler: Subscribe Event Authorization Flow
565+
Client->>AppSync: Request subscription to channel
566+
AppSync->>Lambda: Invoke Lambda with subscribe event
567+
Lambda->>EventHandler: Process subscribe event
568+
alt Authorization Failed
569+
EventHandler->>EventHandler: Authorization check fails
570+
EventHandler->>Lambda: Raise UnauthorizedException
571+
Lambda->>AppSync: Return error response
572+
AppSync--xClient: Subscription denied (HTTP 403)
573+
else Authorization Passed
574+
EventHandler->>Lambda: Return successful response
575+
Lambda->>AppSync: Return authorization success
576+
AppSync->>Client: Subscription established
577+
end
578+
```
579+
</center>
580+
477581
## Testing your code
478582

479583
You can test your event handlers by passing a mocked or actual AppSync Events Lambda event.

0 commit comments

Comments
 (0)