awslabs / amplify-video

An open source Category Plugin for the AWS Amplify-CLI that makes it easy to deploy live and file based streaming video services and integrate them into your Amplify applications.
https://www.npmjs.com/package/amplify-category-video
Apache License 2.0
267 stars 56 forks source link

Edit/Custom MediaConvertStatus Function #297

Open aexei opened 3 years ago

aexei commented 3 years ago

Hey all,

The new function with the SNS Topic is great. How can I customize the Lambda function or automatically assign a Lambda function to the topic as a subscriber?

I already customized "pSnsTopicName" in "parameters.json", but unfortunately the TopicName doesn't change and I can't reference the original name in a function either. Because "MediaConvertNotificationsSNS" is not in the outputs of the video category.

Many greetings Alex

shamikatamazon commented 3 years ago

Hi Aexei - Firstly apologies for the delayed response to your questions.

1 - In order to change the name of the SNS Topic - you can edit provider-utils/awscloudformation/cloudformation-templates/vod-workflow-template.yaml.ejs and change the Default Value under pSnsTopicName

2 - You have a few options to update the Lamda code - You can update the file provider-utils/awscloudformation/cloudformation-templates/vod-helpers/LambdaFunctions/MediaConvertStatusLambda/index.js with your custom code or alternatively update your code in the console for the MediaConvertStatusLambda. If you'd prefer to write your own Lambda and hook it to the SNS Topic, you'll need to define your own Lambda and code and then add in the Lambda->SNS permission and Lambda->SNS subscription

rSNSLambdaPermissions: Type: AWS::Lambda::Permission Properties: FunctionName: !Ref rMediaconvertStatusLambda Action: lambda:InvokeFunction Principal: sns.amazonaws.com SourceArn: !Sub arn:aws:sns:${AWS::Region}:${AWS::AccountId}:*

rSNSLambdaSubscription: Type: AWS::SNS::Subscription Properties: Protocol: lambda Endpoint: !GetAtt rMediaconvertStatusLambda.Arn TopicArn: !Ref MediaConvertNotificationsSNS

Hopefully this helps! Please let me know if you have any additional questions.

wmccracken commented 2 years ago

Hi Aexei - Firstly apologies for the delayed response to your questions. #1 - In order to change the name of the SNS Topic - you can edit provider-utils/awscloudformation/cloudformation-templates/vod-workflow-template.yaml.ejs and change the Default Value under pSnsTopicName

2 - You have a few options to update the Lamda code - You can update the file provider-utils/awscloudformation/cloudformation-templates/vod-helpers/LambdaFunctions/MediaConvertStatusLambda/index.js with your custom code or alternatively update your code in the console for the MediaConvertStatusLambda. If you'd prefer to write your own Lambda and hook it to the SNS Topic, you'll need to define your own Lambda and code and then add in the Lambda->SNS permission and Lambda->SNS subscription

Hi - following up on this, I've got a similar issue. The solutions that you provided are not very portable as they require modifications to the amplify-video package itself or require manually editing the function in the AWS Console. Is there a plan or existing solution that would allow the notification lambda to be modified in the project and checked into version control? I really like the features that amplify video provides but I need to update records in my model when video processing completes and there is no easy way to do this and deploy across multiple environments at this time.

Thanks,

Will