Amazon EventBridge was announced. One aspect of the announcement was added support for custom event buses. Custom buses provide a clean way to isolate events for custom applications. We should be able to specific a custom bus as the source for triggering Lambda functions.
Example template:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
SlackNotify:
Type: AWS::Serverless::Function
Properties:
Handler: main.handler
CodeUri: app/
Runtime: python3.7
Timeout: 5
Events:
AnyRequest:
Type: CloudWatchEvent
Properties:
Bus: example-custom-bus
Pattern:
source:
- example.test
@brandonstevens Thanks for opening this issue. Totally agree this will be a great addition to SAM. However, we're blocked from adding this until Amazon EventBridge adds CloudFormation support. I don't have a confirmed date, but I've heard in public talks that it's "coming soon." I do see an issue for it on CloudFormation's new public coverage roadmap, so that helps.
According to that issue, it will just be a new property added to the existing AWS::Events::Rule resource type. Assuming that's true, this should be fairly trivial to add once the CloudFormation support is there.
This is supported in CFN now!
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Events.html
@zbintliff Yes it is! The change in SAM to support this should be really simple if someone from the community wants to contribute it. Update the CloudWatchEvent source to take an EventBusName property and pass it through to the underlying EventsRule object.
I'll take it. I _think_ i'm mostly there but tests are failing and i can't quite parse why
Hey @jlhood just wondering what the release schedule is for this application?
@zbintliff We're working on making our release process more transparent to external customers, but we're not quite where we want to be yet. For now, you can see when we cut release branches, which can give you some indication of when we begin working on a specific release. Once a release tracker is created you can track its progress on the release board #
Hi Shreya, I took a look at the links and can't really see what will ultimately be included. Do we know if #1185 will make it on #1212 (this is only for our own planning as right now we have to script the creation of these rules)
@jlhood can you double check me? Will my change make sure that the permission on the lambda will allow the CW Rule on the EventBridge external bus to trigger the lambda?
@zbintliff I believe so. If you look at the output file from the unit test you modified, you can see the permission enabled the events.amazonaws.com service principal (EventBridge service) to invoke the Lambda function as long as the source is the AWS::Events::Rule resource ARN:
The AWS::Events::Rule resource is what is specifying the event bus name. The Lambda permission appears to be between the Rule ARN and the Lambda function ARN. It doesn't appear any special extra permission is required based on which event bus the Rule is configured against.
If you want to doublecheck, you can create a native CloudFormation template based off of this output file and verify it works as expected.
Awesome, thanks
Closing this issue as this feature is released in v1.17.0
Most helpful comment
I'll take it. I _think_ i'm mostly there but tests are failing and i can't quite parse why