ListRulesCommand

Lists your Amazon EventBridge rules. You can either list all the rules or you can provide a prefix to match to the rule names.

The maximum number of results per page for requests is 100.

ListRules does not list the targets of a rule. To see the targets associated with a rule, use ListTargetsByRule .

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { EventBridgeClient, ListRulesCommand } from "@aws-sdk/client-eventbridge"; // ES Modules import
// const { EventBridgeClient, ListRulesCommand } = require("@aws-sdk/client-eventbridge"); // CommonJS import
const client = new EventBridgeClient(config);
const input = { // ListRulesRequest
  NamePrefix: "STRING_VALUE",
  EventBusName: "STRING_VALUE",
  NextToken: "STRING_VALUE",
  Limit: Number("int"),
};
const command = new ListRulesCommand(input);
const response = await client.send(command);
// { // ListRulesResponse
//   Rules: [ // RuleResponseList
//     { // Rule
//       Name: "STRING_VALUE",
//       Arn: "STRING_VALUE",
//       EventPattern: "STRING_VALUE",
//       State: "ENABLED" || "DISABLED" || "ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS",
//       Description: "STRING_VALUE",
//       ScheduleExpression: "STRING_VALUE",
//       RoleArn: "STRING_VALUE",
//       ManagedBy: "STRING_VALUE",
//       EventBusName: "STRING_VALUE",
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

ListRulesCommand Input

See ListRulesCommandInput for more details

Parameter
Type
Description
EventBusName
string | undefined

The name or ARN of the event bus to list the rules for. If you omit this, the default event bus is used.

Limit
number | undefined

The maximum number of results to return.

NamePrefix
string | undefined

The prefix matching the rule name.

NextToken
string | undefined

The token returned by a previous call, which you can use to retrieve the next set of results.

The value of nextToken is a unique pagination token for each page. To retrieve the next page of results, make the call again using the returned token. Keep all other arguments unchanged.

Using an expired pagination token results in an HTTP 400 InvalidToken error.

ListRulesCommand Output

See ListRulesCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
NextToken
string | undefined

A token indicating there are more results available. If there are no more results, no token is included in the response.

The value of nextToken is a unique pagination token for each page. To retrieve the next page of results, make the call again using the returned token. Keep all other arguments unchanged.

Using an expired pagination token results in an HTTP 400 InvalidToken error.

Rules
Rule[] | undefined

The rules that match the specified criteria.

Throws

Name
Fault
Details
InternalException
server

This exception occurs due to unexpected causes.

ResourceNotFoundException
client

An entity that you specified does not exist.

EventBridgeServiceException
Base exception class for all service exceptions from EventBridge service.