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"
}
]
}