Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Monitoring

shamikatamazon edited this page Aug 19, 2021 · 6 revisions

Consuming MediaConvert Cloudwatch events

Amplify Video can now automatically send MediaConvert events to an SNS topic. As a user you can consume the events from the SNS topic to monitor the status of jobs and kick off workflows based on the status

The first step in order to send MediaConvert notifications to SNS is to answer "yes" to the question "Do you want to get notifications on the video processing job" during the Amplify CLI walkthrough. This will create an SNS topic named AmplifyMediaConvertStatusEvents and you are able to hook any service to the SNS topic and process events. Note that by default all MediaConvert status events are sent to the topic.

If you answered "yes" to the previous question, you'll get a follow-up option to have Amplify create and associate a placeholder Lambda to process the SNS notifications. You can enable this by answering "yes" to the question "Do you want a custom function executed for notifications?". The name of the Lambda function created is MediaConvertStatusLambda and you are able to edit the code of the Lambda in the console or in your IDE by editing the file "amplify-video/provider-utils/awscloudformation/cloudformation-templates/vod-helpers/LambdaFunctions/MediaConvertStatusLambda/index.js"

If you would prefer to add an SNS topic to monitor MediaConvert jobs using the AWS CLI, please follow the instructions below.

Adding CloudWatch events to Mediaconvert

  1. Install and Configure the AWS CLI
  2. Open a terminal window and run the following command to get your account specific mediaconvert endpoint.
    • aws mediaconvert describe-endpoints
  3. Next, you need to get your account sp
    • aws mediaconvert get-queue --name Default --endpoint-url YOUR-ENDPOINT-URL-HERE
  4. Go to the IAM console and make a service role for cloudwatch.
  5. Once created, click on the role in the name to enter the "Role Summary Page". From here click the blue Attach Policies button and attach the policy named "AWSElementalMediaConvertReadOnly".
  6. Now that your role has been created and configured, create the CloudWatch Event rule by running the following command.
    • aws events put-rule --name "TranscodeJobStateChanges" --event-pattern "{ \"source\": [ \"aws.mediaconvert\" ], \"detail-type\": [ \"MediaConvert Job State Change\" ], \"detail\": { \"queue\": [ \"YOUR_QUEUE_ARN\" ], \"status\": [ \"COMPLETE\", \"ERROR\" ] } }" --role-arn "CLOUDWATCH_EVENT_ROLE_ARN"

Notifications

  1. If you want to recieve notifications from your Cloudwatch Event. Create an SNS topic in the SNS Console, then run the following command.
    • aws events put-targets --rule TranscodeJobStateChanges --targets "Id"="1","Arn"="SNS_TOPIC_ARN"

Clone this wiki locally