Event Handler for AWS AppSync real-time events. Key FeaturesAWS AppSync Events{target="_blank"}. A service that enables you to quickly build secure, scalable real-time WebSocket APIs without managing infrastructure or writing API code. It handles connection management, message broadcasting, authentication, and monitoring, reducing time to market and operational costs.
Getting Starteddotnet add package AWS.Lambda.Powertools.EventHandler --version 1.0.0
AWS.Lambda.Powertools.EventHandler
namespace to your Lambda function:using AWS.Lambda.Powertools.EventHandler;
AppSyncEventsResolver
async Task<AppSyncEventsResponse> Handler(AppSyncEventsRequest appSyncEvent, ILambdaContext context)
{
return await app.ResolveAsync(appSyncEvent, context);
}
Example
using AWS.Lambda.Powertools.EventHandler;
using Amazon.Lambda.Core;
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;
using AWS.Lambda.Powertools.EventHandler.AppSyncEvents;
using AWS.Lambda.Powertools.Logging;
var app = new AppSyncEventsResolver();
app.OnPublishAsync("/default/channel", async (payload) =>
{
Logger.LogInformation("Published to /default/channel with {@payload}", payload);
if (payload["eventType"].ToString() == "data_2")
{
throw new Exception("Error in /default/channel");
}
return "Hello from /default/channel";
});
app.OnPublishAggregateAsync("/default/channel2", async (payload) =>
{
var evt = new List<AppSyncEvent>();
foreach (var item in payload.Events)
{
var pd = new AppSyncEvent
{
Id = item.Id,
Payload = new Dictionary<string, object>
{
{ "demo", "demo" }
}
};
if (item.Payload["eventType"].ToString() == "data_2")
{
pd.Payload["message"] = "Hello from /default/channel2 with data_2";
pd.Payload["data"] = new Dictionary<string, object>
{
{ "key", "value" }
};
}
evt.Add(pd);
}
Logger.LogInformation("Published to /default/channel2 with {@evt}", evt);
return new AppSyncEventsResponse
{
Events = evt
};
});
app.OnSubscribeAsync("/default/*", async (payload) =>
{
Logger.LogInformation("Subscribed to /default/* with {@payload}", payload);
return true;
});
async Task<AppSyncEventsResponse> Handler(AppSyncEventsRequest appSyncEvent, ILambdaContext context)
{
return await app.ResolveAsync(appSyncEvent, context);
}
await LambdaBootstrapBuilder.Create((Func<AppSyncEventsRequest, ILambdaContext, Task<AppSyncEventsResponse>>)Handler,
new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
Product Versions Compatible and additional computed target framework versions. .NET net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. NuGet packages
This package is not used by any NuGet packages.
GitHub repositoriesThis package is not used by any popular GitHub repositories.
Version Downloads Last Updated 1.0.1 134 7/2/2025 1.0.0 169 4/24/2025Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4