Last active
May 26, 2020 09:21
-
-
Save yoshihitoh/b804ad048523e02cbec335e8e0a2301c to your computer and use it in GitHub Desktop.
CDKでS3⇢Step Functions
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
import * as events from '@aws-cdk/aws-events'; | |
import * as s3 from '@aws-cdk/aws-s3'; | |
import * as sfn from '@aws-cdk/aws-stepfunctions'; | |
import * as targets from '@aws-cdk/aws-events-targets'; | |
function cloudTrailS3Event(bucket: s3.IBucket, detailType: string, grantOps: string[]): events.EventPattern { | |
return { | |
source: ["aws.s3"], | |
detailType: [detailType], | |
detail: { | |
eventSource: ["s3.amazonaws.com"], | |
eventName: grantOps, | |
requestParameters: { | |
bucketName: [bucket.bucketName], | |
} | |
} | |
}; | |
} | |
const grantOps = ["CompleteMultipartUpload", "PutObject", "CopyObject"]; | |
const rule = new events.Rule(this, "s3-event-rule", { | |
enabled: true, | |
}); | |
rule.addEventPattern(cloudTrailS3Event(bucket, "AWS API Call via CloudTrail", grantOps)); | |
rule.addTarget(new targets.SfnStateMachine(stateMachine)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment