I'm using a Lambda function to do some processing on uploaded files (image resizing, video conversion etc) However im struggling to get the lambda function to get anything from S3.
Currently got the Lambda function running on S3 Upload trigger and all it has to do right not is copy the file from one bucket to another but it just seems to freeze.
I get a log in CloudWatch stating it started, I get the File Uploaded... message and then nothing until the function times out, which happens no matter how much memory or timeout I give it.
At first i thought it might be permissions but my lambda user has FullPermission on S3 as well as Lambda and i've even made my buckets public.
function code im using is:
public async Task<string> FunctionHandler(S3Event evnt, ILambdaContext context)
{
var s3Event = evnt.Records?[0].S3;
if(s3Event == null) return null;
try
{
context.Logger.LogLine("File Uploaded, Starting Copy");
await S3Client.CopyObjectAsync(s3Event.Bucket.Name, s3Event.Object.Key, destinationBucket, s3Event.Object.Key);
context.Logger.LogLine("Copy Completed.");
return "Finished";
}
catch(Exception e)
{
context.Logger.LogLine($"Error getting object {s3Event.Object.Key} from bucket {s3Event.Bucket.Name}. Make sure they exist and your bucket is in the same region as this function.");
context.Logger.LogLine(e.Message);
context.Logger.LogLine(e.StackTrace);
throw;
}
}