0

I'm trying to construct VOD converting system with Lambda and MediaConvert. I've defined lambda function to request MediaConvert to convert files to HLS. And I've added a trigger to execute lambda function as soon as original files upload into original S3 bucket. What I ultimately want to do here is to store transcoded files into Output S3 bucket. But when I test it, it looks working fine and returns 201 code. but nothing in the Output s3 bucket. Both Lambda and MediaConvert have every role to access resources needed. I spent 2days to figure out the problem, but had no idea what is wrong.

a part of Lambda Function I wrote:

    jobMetadata = {'assetId': resourceKey}

    print (json.dumps(event))
    
    try:
        with open('job.json') as json_data:
            jobSettings = json.load(json_data)
            print(jobSettings)
        
        mc_client = boto3.client('mediaconvert', region_name=region)
        endpoints = mc_client.describe_endpoints()

        client = boto3.client('mediaconvert', region_name=region, endpoint_url=endpoints['Endpoints'][0]['Url'], verify=False)

        jobSettings['Inputs'][0]['FileInput'] = originS3Path
        
/////some path definition///


        print('jobSettings:')
        print(json.dumps(jobSettings))

        job = client.create_job(Role=mediaConvertRole, UserMetadata=jobMetadata, Settings=jobSettings)
        print (json.dumps(job, default=str))

CloudWatch log:

{"ResponseMetadata": {"RequestId": "5a2ce993-3295-4ae8-93f4-04cd2829694e", "HTTPStatusCode": 201, .....

Lambda Role: (Lambda has AmazonS3FullAccess Role, AWSLambdaBasicExecutionRole and following in-line policy)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*",
            "Effect": "Allow",
            "Sid": "Logging"
        },
        {
            "Action": [
                "iam:PassRole"
            ],
            "Resource": [
                "my role arn"
            ],
            "Effect": "Allow",
            "Sid": "PassRole"
        },
        {
            "Action": [
                "mediaconvert:*"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow",
            "Sid": "MediaConvertService"
        },
        {
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow",
            "Sid": "S3Service"
        }
    ]
}
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Taylor
  • 25
  • 4
  • Have you set the environment variables? – jellycsc Jul 12 '22 at 12:30
  • I'm not familiar with Media Convert, but it looks like your code is calling `create_job()` on `mediaconvert`. Have you gone into Media Convert in the AWS management console to see if the job was created? – John Rotenstein Jul 12 '22 at 23:32
  • @jellycsc yes all set – Taylor Jul 13 '22 at 02:07
  • Based on the code snippet and response message, the Create Job API call was successful. This means that the job should show up in the MediaConvert Console. When you view the job’s details, does it show as completed or do you see an error message? For the latter, what is the error message returned? Viewing your AWS Elemental MediaConvert job history : https://docs.aws.amazon.com/mediaconvert/latest/ug/viewing-job-history.html – aws-slm Jul 16 '22 at 18:36

0 Answers0