Skip to main content

rules

Creates, updates, deletes or gets a rule resource or lists rules in a region

Overview

Namerules
TypeResource
DescriptionResource Type definition for AWS::Events::Rule
Idawscc.events.rules

Fields

NameDatatypeDescription
event_bus_namestringThe name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.
event_patternobjectThe event pattern of the rule. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.
schedule_expressionstringThe scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)". For more information, see Creating an Amazon EventBridge rule that runs on a schedule.
descriptionstringThe description of the rule.
statestringThe state of the rule.
targetsarrayAdds the specified targets to the specified rule, or updates the targets if they are already associated with the rule.<br />Targets are the resources that are invoked when a rule is triggered.
arnstringThe ARN of the rule, such as arn:aws:events:us-east-2:123456789012:rule/example.
role_arnstringThe Amazon Resource Name (ARN) of the role that is used for target invocation.
tagsarrayAny tags assigned to the event rule.
namestringThe name of the rule.
regionstringAWS region.

For more information, see AWS::Events::Rule.

Methods

NameResourceAccessible byRequired Params
create_resourcerulesINSERTregion
delete_resourcerulesDELETEIdentifier, region
update_resourcerulesUPDATEIdentifier, PatchDocument, region
list_resourcesrules_list_onlySELECTregion
get_resourcerulesSELECTIdentifier, region

SELECT examples

Gets all properties from an individual rule.

SELECT
region,
event_bus_name,
event_pattern,
schedule_expression,
description,
state,
targets,
arn,
role_arn,
tags,
name
FROM awscc.events.rules
WHERE
region = 'us-east-1' AND
Identifier = '{{ arn }}';

INSERT example

Use the following StackQL query and manifest file to create a new rule resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.events.rules (
EventBusName,
EventPattern,
ScheduleExpression,
Description,
State,
Targets,
RoleArn,
Tags,
Name,
region
)
SELECT
'{{ event_bus_name }}',
'{{ event_pattern }}',
'{{ schedule_expression }}',
'{{ description }}',
'{{ state }}',
'{{ targets }}',
'{{ role_arn }}',
'{{ tags }}',
'{{ name }}',
'{{ region }}';

UPDATE example

Use the following StackQL query and manifest file to update a rule resource, using stack-deploy.

/*+ update */
UPDATE awscc.events.rules
SET PatchDocument = string('{{ {
"EventBusName": event_bus_name,
"EventPattern": event_pattern,
"ScheduleExpression": schedule_expression,
"Description": description,
"State": state,
"Targets": targets,
"RoleArn": role_arn,
"Tags": tags
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ arn }}';

DELETE example

/*+ delete */
DELETE FROM awscc.events.rules
WHERE
Identifier = '{{ arn }}' AND
region = 'us-east-1';

Permissions

To operate on the rules resource, the following permissions are required:

iam:PassRole,
events:DescribeRule,
events:ListTargetsByRule,
events:ListTagsForResource