/AWS1/IF_CWE=>PUTRULE()¶
About PutRule¶
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.
Method Signature¶
METHODS /AWS1/IF_CWE~PUTRULE
IMPORTING
!IV_NAME TYPE /AWS1/CWERULENAME OPTIONAL
!IV_SCHEDULEEXPRESSION TYPE /AWS1/CWESCHEDULEEXPRESSION OPTIONAL
!IV_EVENTPATTERN TYPE /AWS1/CWEEVENTPATTERN OPTIONAL
!IV_STATE TYPE /AWS1/CWERULESTATE OPTIONAL
!IV_DESCRIPTION TYPE /AWS1/CWERULEDESCRIPTION OPTIONAL
!IV_ROLEARN TYPE /AWS1/CWEROLEARN OPTIONAL
!IT_TAGS TYPE /AWS1/CL_CWETAG=>TT_TAGLIST OPTIONAL
!IV_EVENTBUSNAME TYPE /AWS1/CWEEVENTBUSNAMEORARN OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_cweputruleresponse
RAISING
/AWS1/CX_CWECONCURRENTMODEX
/AWS1/CX_CWEINTERNALEXCEPTION
/AWS1/CX_CWEINVEVENTPATTERNEX
/AWS1/CX_CWELIMITEXCEEDEDEX
/AWS1/CX_CWEMANAGEDRULEEX
/AWS1/CX_CWERESOURCENOTFOUNDEX
/AWS1/CX_CWECLIENTEXC
/AWS1/CX_CWESERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_name TYPE /AWS1/CWERULENAME /AWS1/CWERULENAME¶
The name of the rule that you are creating or updating.
Optional arguments:¶
iv_scheduleexpression TYPE /AWS1/CWESCHEDULEEXPRESSION /AWS1/CWESCHEDULEEXPRESSION¶
The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".
iv_eventpattern TYPE /AWS1/CWEEVENTPATTERN /AWS1/CWEEVENTPATTERN¶
The event pattern. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.
iv_state TYPE /AWS1/CWERULESTATE /AWS1/CWERULESTATE¶
Indicates whether the rule is enabled or disabled.
iv_description TYPE /AWS1/CWERULEDESCRIPTION /AWS1/CWERULEDESCRIPTION¶
A description of the rule.
iv_rolearn TYPE /AWS1/CWEROLEARN /AWS1/CWEROLEARN¶
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
RoleArnwith proper permissions in theTargetstructure, instead of here in this parameter.
it_tags TYPE /AWS1/CL_CWETAG=>TT_TAGLIST TT_TAGLIST¶
The list of key-value pairs to associate with the rule.
iv_eventbusname TYPE /AWS1/CWEEVENTBUSNAMEORARN /AWS1/CWEEVENTBUSNAMEORARN¶
The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_cweputruleresponse /AWS1/CL_CWEPUTRULERESPONSE¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->putrule(
it_tags = VALUE /aws1/cl_cwetag=>tt_taglist(
(
new /aws1/cl_cwetag(
iv_key = |string|
iv_value = |string|
)
)
)
iv_description = |string|
iv_eventbusname = |string|
iv_eventpattern = |string|
iv_name = |string|
iv_rolearn = |string|
iv_scheduleexpression = |string|
iv_state = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_rulearn = lo_result->get_rulearn( ).
ENDIF.