Documentation for !Ref of an AWS::Events::Rule not fully documented
Name of the resource
AWS::Events::Rule
Resource name
No response
Reference Link
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule-return-values
Details
In https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule-return-values, the return value for the !Ref of a Rule is
Ref returns event rule ID, such as
mystack-ScheduledRule-ABCDEFGHIJK
I have seen that Rules return "busname|rulename" as the value of !Ref. I am actually using the return value of !Ref on an Event this to monitor the rule like this:
BusInvocationErrors:
Type: AWS::CloudWatch::Alarm
Properties:
ActionsEnabled: true
AlarmDescription: !Sub 'FailedInvocations in ${AWS::StackName}'
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Name: EventBusName
Value: !Select [ 0, !Split [ '|', !Ref Rule ] ]
- Name: RuleName
Value: !Select [ 1, !Split [ '|', !Ref Rule ] ]
Period: 60
EvaluationPeriods: 1
MetricName: FailedInvocations
Namespace: AWS/Events
Statistic: Sum
I would suggest that the return value be correctly documented.
8 months into having reported this, and it bit me again (didn't even remember reporting it). Is this going to get corrected?
When the rule is in the default event bus of the same account, just the rule name is returned. Otherwise, eventbusname|rulename is returned to be able to differentiate between rules in different buses. This is an expected behaviour and we will update the docs.