Last active
July 22, 2022 08:19
-
-
Save jbesw/08469b18bc45eed1f4b2c0783d132f5d to your computer and use it in GitHub Desktop.
EventBridge Rule for Logging to CloudWatch Logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: EventBridge Rule Test | |
Resources: | |
CFNLogGroup: | |
Type: AWS::Logs::LogGroup | |
Properties: | |
RetentionInDays: 3 | |
LogGroupName: '/aws/events/eventbridgeLog' | |
MyALLRule: | |
Type: AWS::Events::Rule | |
Properties: | |
Description: Collects everything | |
EventPattern: | |
account: | |
- "123412341234" | |
RoleArn: !GetAtt EBAllRole.Arn | |
Targets: | |
- Id: 'CloudwatchLogsTarget' | |
Arn: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${CFNLogGroup}" | |
EBAllRole: | |
Type: "AWS::IAM::Role" | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- | |
Effect: "Allow" | |
Principal: | |
Service: "events.amazonaws.com" | |
Action: | |
- "sts:AssumeRole" | |
Policies: | |
- PolicyName: AllowAllEventsToBeLogged | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
Effect: Allow | |
Action: | |
- logs:CreateLogStream | |
- logs:PutLogEvents | |
Resource: '*' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @jbesw! I'm trying to do this with a
Rule
with a specificEventBusName
, but it doesn't seem to be working (no log streams created, no logs).Is there something different about how custom buses work that affects log delivery? Is the custom bus the reason you're using an
AWS::Logs::ResourcePolicy
here instead of this Role-based permission ☝️ ?