Amazon EventBridge

2023/11/17 - Amazon EventBridge - 3 updated api methods

Changes  Introduces a new rule state ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS for matching with Get, List and Describe AWS API call events from CloudTrail.

DescribeRule (updated) Link ¶
Changes (response)
{'State': {'ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS'}}

Describes the specified rule.

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

See also: AWS API Documentation

Request Syntax

client.describe_rule(
    Name='string',
    EventBusName='string'
)
type Name

string

param Name

[REQUIRED]

The name of the rule.

type EventBusName

string

param EventBusName

The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.

rtype

dict

returns

Response Syntax

{
    'Name': 'string',
    'Arn': 'string',
    'EventPattern': 'string',
    'ScheduleExpression': 'string',
    'State': 'ENABLED'|'DISABLED'|'ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS',
    'Description': 'string',
    'RoleArn': 'string',
    'ManagedBy': 'string',
    'EventBusName': 'string',
    'CreatedBy': 'string'
}

Response Structure

  • (dict) --

    • Name (string) --

      The name of the rule.

    • Arn (string) --

      The Amazon Resource Name (ARN) of the rule.

    • EventPattern (string) --

      The event pattern. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide .

    • ScheduleExpression (string) --

      The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)".

    • State (string) --

      Specifies whether the rule is enabled or disabled.

    • Description (string) --

      The description of the rule.

    • RoleArn (string) --

      The Amazon Resource Name (ARN) of the IAM role associated with the rule.

    • ManagedBy (string) --

      If this is a managed rule, created by an Amazon Web Services service on your behalf, this field displays the principal name of the Amazon Web Services service that created the rule.

    • EventBusName (string) --

      The name of the event bus associated with the rule.

    • CreatedBy (string) --

      The account ID of the user that created the rule. If you use PutRule to put a rule on an event bus in another account, the other account is the owner of the rule, and the rule ARN includes the account ID for that account. However, the value for CreatedBy is the account ID as the account that created the rule in the other account.

ListRules (updated) Link ¶
Changes (response)
{'Rules': {'State': {'ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS'}}}

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 .

See also: AWS API Documentation

Request Syntax

client.list_rules(
    NamePrefix='string',
    EventBusName='string',
    NextToken='string',
    Limit=123
)
type NamePrefix

string

param NamePrefix

The prefix matching the rule name.

type EventBusName

string

param EventBusName

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

type NextToken

string

param NextToken

The token returned by a previous call to retrieve the next set of results.

type Limit

integer

param Limit

The maximum number of results to return.

rtype

dict

returns

Response Syntax

{
    'Rules': [
        {
            'Name': 'string',
            'Arn': 'string',
            'EventPattern': 'string',
            'State': 'ENABLED'|'DISABLED'|'ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS',
            'Description': 'string',
            'ScheduleExpression': 'string',
            'RoleArn': 'string',
            'ManagedBy': 'string',
            'EventBusName': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Rules (list) --

      The rules that match the specified criteria.

      • (dict) --

        Contains information about a rule in Amazon EventBridge.

        • Name (string) --

          The name of the rule.

        • Arn (string) --

          The Amazon Resource Name (ARN) of the rule.

        • EventPattern (string) --

          The event pattern of the rule. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide .

        • State (string) --

          The state of the rule.

          Valid values include:

          • DISABLED : The rule is disabled. EventBridge does not match any events against the rule.

          • ENABLED : The rule is enabled. EventBridge matches events against the rule, except for Amazon Web Services management events delivered through CloudTrail.

          • ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS : The rule is enabled for all events, including Amazon Web Services management events delivered through CloudTrail. Management events provide visibility into management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. For more information, see Logging management events in the CloudTrail User Guide , and Filtering management events from Amazon Web Services services in the Amazon EventBridge User Guide . This value is only valid for rules on the default event bus or custom event buses . It does not apply to partner event buses .

        • Description (string) --

          The description of the rule.

        • ScheduleExpression (string) --

          The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)". For more information, see Creating an Amazon EventBridge rule that runs on a schedule .

        • RoleArn (string) --

          The Amazon Resource Name (ARN) of the role that is used for target invocation.

          If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a RoleArn with proper permissions in the Target structure, instead of here in this parameter.

        • ManagedBy (string) --

          If the rule was created on behalf of your account by an Amazon Web Services service, this field displays the principal name of the service that created the rule.

        • EventBusName (string) --

          The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.

    • NextToken (string) --

      Indicates whether there are additional results to retrieve. If there are no more results, the value is null.

PutRule (updated) Link ¶
Changes (request)
{'State': {'ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS'}}

Creates or updates the specified rule. Rules are enabled by default, or based on value of the state. You can disable a rule using DisableRule .

A single rule watches for events from a single event bus. Events generated by Amazon Web Services services go to your account's default event bus. Events generated by SaaS partner services or applications go to the matching partner event bus. If you have custom applications or services, you can specify whether their events go to your default event bus or a custom event bus that you have created. For more information, see CreateEventBus .

If you are updating an existing rule, the rule is replaced with what you specify in this PutRule command. If you omit arguments in PutRule , the old values for those arguments are not kept. Instead, they are replaced with null values.

When you create or update a rule, incoming events might not immediately start matching to new or updated rules. Allow a short period of time for changes to take effect.

A rule must contain at least an EventPattern or ScheduleExpression. Rules with EventPatterns are triggered when a matching event is observed. Rules with ScheduleExpressions self-trigger based on the given schedule. A rule can have both an EventPattern and a ScheduleExpression, in which case the rule triggers on matching events as well as on a schedule.

When you initially create a rule, you can optionally assign one or more tags to the rule. Tags can help you organize and categorize your resources. You can also use them to scope user permissions, by granting a user permission to access or change only rules with certain tag values. To use the PutRule operation and assign tags, you must have both the events:PutRule and events:TagResource permissions.

If you are updating an existing rule, any tags you specify in the PutRule operation are ignored. To update the tags of an existing rule, use TagResource and UntagResource .

Most services in Amazon Web Services treat : or / as the same character in Amazon Resource Names (ARNs). However, EventBridge uses an exact match in event patterns and rules. Be sure to use the correct ARN characters when creating event patterns so that they match the ARN syntax in the event you want to match.

In EventBridge, it is possible to create rules that lead to infinite loops, where a rule is fired repeatedly. For example, a rule might detect that ACLs have changed on an S3 bucket, and trigger software to change them to the desired state. If the rule is not written carefully, the subsequent change to the ACLs fires the rule again, creating an infinite loop.

To prevent this, write the rules so that the triggered actions do not re-fire the same rule. For example, your rule could fire only if ACLs are found to be in a bad state, instead of after any change.

An infinite loop can quickly cause higher than expected charges. We recommend that you use budgeting, which alerts you when charges exceed your specified limit. For more information, see Managing Your Costs with Budgets .

See also: AWS API Documentation

Request Syntax

client.put_rule(
    Name='string',
    ScheduleExpression='string',
    EventPattern='string',
    State='ENABLED'|'DISABLED'|'ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS',
    Description='string',
    RoleArn='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    EventBusName='string'
)
type Name

string

param Name

[REQUIRED]

The name of the rule that you are creating or updating.

type ScheduleExpression

string

param ScheduleExpression

The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".

type EventPattern

string

param EventPattern

The event pattern. For more information, see Amazon EventBridge event patterns in the Amazon EventBridge User Guide .

type State

string

param State

The state of the rule.

Valid values include:

  • DISABLED : The rule is disabled. EventBridge does not match any events against the rule.

  • ENABLED : The rule is enabled. EventBridge matches events against the rule, except for Amazon Web Services management events delivered through CloudTrail.

  • ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS : The rule is enabled for all events, including Amazon Web Services management events delivered through CloudTrail. Management events provide visibility into management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. For more information, see Logging management events in the CloudTrail User Guide , and Filtering management events from Amazon Web Services services in the Amazon EventBridge User Guide . This value is only valid for rules on the default event bus or custom event buses . It does not apply to partner event buses .

type Description

string

param Description

A description of the rule.

type RoleArn

string

param RoleArn

The Amazon Resource Name (ARN) of the IAM role associated with the rule.

If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a RoleArn with proper permissions in the Target structure, instead of here in this parameter.

type Tags

list

param Tags

The list of key-value pairs to associate with the rule.

  • (dict) --

    A key-value pair associated with an Amazon Web Services resource. In EventBridge, rules and event buses support tagging.

    • Key (string) -- [REQUIRED]

      A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.

    • Value (string) -- [REQUIRED]

      The value for the specified tag key.

type EventBusName

string

param EventBusName

The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.

rtype

dict

returns

Response Syntax

{
    'RuleArn': 'string'
}

Response Structure

  • (dict) --

    • RuleArn (string) --

      The Amazon Resource Name (ARN) of the rule.