Skip to content

Instantly share code, notes, and snippets.

@eoinsha
Created March 12, 2020 07:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eoinsha/e1c3dcf748f2792d621d297493859df2 to your computer and use it in GitHub Desktop.
Save eoinsha/e1c3dcf748f2792d621d297493859df2 to your computer and use it in GitHub Desktop.
EventBridge CloudTrail Data Events and S3 Notification SAM YAML
NotificationFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: handlers/
Handler: notification.handleS3Notification
Runtime: nodejs12.x
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
Resource:
- arn:aws:s3:::s3-trigger-compare/uploads/*
Events:
NotificationEvent:
Type: S3
Properties:
Bucket: !Ref TriggerBucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: 'uploads/'
EventBridgeFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: handlers/
Handler: event-bridge.handleEvent
Runtime: nodejs12.x
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
Resource:
- arn:aws:s3:::s3-trigger-compare/uploads/*
Events:
EventBridgeEvent:
Type: EventBridgeRule
Properties:
Pattern:
source:
- aws.s3
detail-type:
- AWS API Call via CloudTrail
detail:
eventSource:
- s3.amazonaws.com
eventName:
- CopyObject
- PutObject
- CompleteMultipartUpload
- RestoreObject
requestParameters:
bucketName:
- !Ref TriggerBucket
key:
- prefix: 'uploads/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment