Search code examples
amazon-web-servicesaws-lambdaamazon-dynamodbamazon-cloudwatchaws-media-live

How to trigger Lambda function on MediaLive Channel creation?


Complete newbie to AWS and having trouble with this problem. I want to trigger a Lambda function upon the initial spin-up of an AWS MediaLive Channel that adds the channel details to a DynamoDB table. I'm having trouble finding a way to set this trigger.

I have tried using CloudWatch logs as a trigger, but it looks like the logs might only be generated when the channel has started, not when the channel is created, although I could be reading something wrong. I wanted to create a new test channel to see if its creation would show up in the CloudWatch logs, but unfortunately we've hit the upper limit of channels we can create and I'm not allowed to delete any currently existing ones. Any help (and any general Lambda function writing tips) would be appreciated.


Solution

  • The CreateChannel event will appear in CloudTrail and on the EventBus. An eventbus rule can watch for said events and trigger the Lambda in response.

    This example from the aws-samples github has lambda code which reacts to event bus events. https://github.com/aws-samples/aws-medialive-fallback-switcher-lambda