Code examples for EventBridge using Amazon SDKs - Amazon EventBridge
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Code examples for EventBridge using Amazon SDKs

The following code examples show how to use EventBridge with an Amazon software development kit (SDK).

Actions are code excerpts that show you how to call individual service functions.

Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Cross-service examples are sample applications that work across multiple Amazon Web Services.

For a complete list of Amazon SDK developer guides and code examples, see Using EventBridge with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.

Get started

The following code example shows how to get started using EventBridge.

Amazon SDK for .NET

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

using Microsoft.Extensions.Hosting; using Amazon.EventBridge; using Amazon.EventBridge.Model; using Amazon.Extensions.NETCore.Setup; using Microsoft.Extensions.DependencyInjection; namespace EventBridgeActions; public static class HelloEventBridge { static async Task Main(string[] args) { // Use the AWS .NET Core Setup package to set up dependency injection for the Amazon EventBridge service. // Use your AWS profile name, or leave it blank to use the default profile. using var host = Host.CreateDefaultBuilder(args) .ConfigureServices((_, services) => services.AddAWSService<IAmazonEventBridge>(new AWSOptions() { Profile = "default" }) ).Build(); // Now the client is available for injection. var eventBridgeClient = host.Services.GetRequiredService<IAmazonEventBridge>(); Console.WriteLine($"Hello Amazon EventBridge! Following are some of your EventBuses:"); Console.WriteLine(); // You can use await and any of the async methods to get a response. // Let's get the first five event buses. var response = await eventBridgeClient.ListEventBusesAsync( new ListEventBusesRequest() { Limit = 5 }); foreach (var eventBus in response.EventBuses) { Console.WriteLine($"\tEventBus: {eventBus.Name}"); Console.WriteLine($"\tArn: {eventBus.Arn}"); Console.WriteLine($"\tPolicy: {eventBus.Policy}"); Console.WriteLine(); } } }
  • For API details, see ListEventBuses in Amazon SDK for .NET API Reference.