This is a lambda that will convert S3 objects with a .mov
extension to .mp4
files. It downloads the .mov
file, performs the conversion with ffmpeg
, then reuploads the .mp4
file.
Clone the repository, then run the following:
$ npm install
$ cp .env.sample .env
$ cp deploy.env.sample deploy.env
$ cp event.json.sample event.json
In .env
, replace the value of AWS_ROLE_ARN
with the value you create below in "Create a role".
Replace other config values as necessary,
In deploy.env
, add your own secret values to use when sending the email notification with SendGrid. The values are:
FROM_EMAIL
: The email address you'd like the notification to appear to be sent fromTO_EMAIL
: The email address you'd like the notification to be sent toSENDGRID_API_KEY
: Your SendGrid API key. If necessary, you can create a new one here
First create an IAM policy that has full Get
and Put
access to your S3 bucket, then in the
IAM roles console, create a new role. When you're prompted to
choose a role type, select "AWS Lambda." When you're prompted to attach policies, attach the one you just created and
the one named "CloudWatchLogsFullAccess."
Once you've finished creating the role, copy the ARN and put it in .env
as mentioned above.
To run the lambda function locally using the contents of event.json
as the payload, run:
$ npm run local
To deploy the lambda to AWS, run:
$ npm run deploy
If you want to package the lambda as a zip file for manual upload to AWS, run:
$ npm run package
In the AWS lambda console, add a trigger for your function. Specify the bucket you want to monitor, the event type as "Object Created (All)", and the suffix as ".mov". It should look like this: