如何将AWS MediaConverter事件对接至SNS而非CloudWatch?
Absolutely, I’ve set up this exact workflow multiple times—here’s a step-by-step breakdown of how to configure AWS MediaConvert to send event notifications to SNS, plus some best practices I’ve picked up along the way:
Step 1: Create an SNS Topic for MediaConvert Events
First, you’ll need a dedicated SNS topic to receive MediaConvert’s event messages. Here’s what to do:
- Go to the SNS console, create a new topic (standard works for most use cases; pick FIFO only if you need strict message ordering).
- Critical: Update the topic’s resource policy to allow the MediaConvert service principal to publish to it. Without this, MediaConvert won’t be able to send events. Here’s a sample policy you can adapt:
{ "Version": "2008-10-17", "Id": "MediaConvertSNSPolicy", "Statement": [ { "Sid": "AllowMediaConvertPublish", "Effect": "Allow", "Principal": { "Service": "mediaconvert.amazonaws.com" }, "Action": "sns:Publish", "Resource": "arn:aws:sns:YOUR_REGION:YOUR_ACCOUNT_ID:YOUR_TOPIC_NAME" } ] }
- Replace
YOUR_REGION,YOUR_ACCOUNT_ID, andYOUR_TOPIC_NAMEwith your actual values.
Step 2: Configure MediaConvert Job Notifications
Next, tell MediaConvert to send events to your SNS topic. You can do this per-job or via a preset (for consistent settings across jobs):
- Per-job configuration: When creating a new MediaConvert job, scroll to "Job settings", expand "Notifications".
- Toggle on "Enable notifications".
- Paste your SNS topic ARN into the "SNS topic" field.
- Select the event types you want:
COMPLETE(job succeeded),ERROR(job failed),PROGRESSING(job in progress), orALL.
- Preset configuration: If you use presets for jobs, add notification settings directly to the preset. This ensures every job using the preset inherits the setup, saving time for repeated workflows.
Step 3: Subscribe to the SNS Topic
Once the topic is ready, subscribe an endpoint to receive messages. Common options include:
- Lambda function: Ideal for automated workflows (e.g., triggering file transfers, updating databases, or sending Slack alerts). Just ensure your Lambda execution role has the
sns:ReceiveMessagepermission. - Email/SMS: Great for quick human alerts (e.g., when a job fails and needs manual intervention).
- SQS queue: Useful if you need to batch process messages or decouple your workflow from immediate execution.
Key Best Practices & Troubleshooting Tips
From hands-on experience, these are the most common pitfalls and fixes:
- Double-check permissions: It’s easy to forget either the SNS topic’s resource policy or the MediaConvert job role’s permissions. Ensure your MediaConvert execution role has the
sns:Publishpermission for your topic ARN. - Test with a small job: Create a short test video conversion job to verify events are sent and received. Check the SNS topic’s "Metrics" tab to confirm publish requests are going through.
- Parse the payload correctly: MediaConvert’s SNS messages include a
Messagefield that’s a JSON string with full job details (output locations, error codes, progress percentage). In subscribers like Lambda, useJSON.parse(event.Records[0].Sns.Message)to extract this data. - Handle retries: SNS retries message delivery if the subscriber returns an error. Make sure your subscriber (e.g., Lambda function) is idempotent to avoid duplicate processing.
内容的提问来源于stack exchange,提问作者IRCodder
相关产品推荐
相关产品推荐

