Follow the steps in: http://docs.aws.amazon.com/codecommit/latest/userguide/how-to-notify-lambda.html
Below is my summary of what you need to do.
- Visit AWS SNS control panel > Topics > Create topic, name = "commits" or something
- Create Subscription to topic > email
- Visit IAM control panel > Roles > Create Role
- Service role: Lambda
- Add AWSCodeCommitFullAccess policy
- Add AmazonSNSFullAccess policy
-
Visit AWS Lambda control panel > Dashboard
-
Create Function > blueprint = Author from scratch
-
Configure triggers dialogue: click on dashed box, choose CodeCommit, make up a trigger name
-
Configure function dialogue: name something like CodeCommitLambdaFunction, Runtime = Python 2.7
-
Existing role: service-role/CodeCommitLambdaRole
-
paste code from this gist, CodeCommitLambdaFunction_allEvents.py
-
uncomment print of "Received event"
-
Save
-
Commit and push to repo. The Lambda function should get triggered.
-
Go to the Lambda function you created, Monitoring tab, View Logs in CloudWatch, choose event, view in plain text.
-
Grab the text of the incoming event in order to create a test input for your function.
-
Back to Code tab
-
Actions > Configure Test Event
-
paste in '{ "Records" : [ ... ] }' you copied from logs. Save and Test.