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).
List EventBridge targets for a rule using an Amazon SDK
The following code example shows how to list Amazon EventBridge targets for a rule.
- .NET
-
- Amazon SDK for .NET
-
List all of the targets for a rule using the rule name.
/// <summary>
/// List all of the targets matching a rule by name.
/// </summary>
/// <param name="ruleName">The name of the rule.</param>
/// <returns>The list of targets.</returns>
public async Task<List<Target>> ListAllTargetsOnRule(string ruleName)
{
var results = new List<Target>();
var request = new ListTargetsByRuleRequest()
{
Rule = ruleName
};
ListTargetsByRuleResponse response;
do
{
response = await _amazonEventBridge.ListTargetsByRuleAsync(request);
results.AddRange(response.Targets);
request.NextToken = response.NextToken;
} while (response.NextToken is not null);
return results;
}
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.