create_export_task returns success but does not export data to s3 from cloudwatch

Question:

I have logs on cloudwatch which I want to store on S3 everyday. I am using AWS Lambda to achieve this.

I created a function on AWS Lambda and I use Cloudwatch event as the trigger. This created an event rule on Cloudwatch. Now when I execute this lambda function, it executes successfully and a file with name ‘aws-log-write-test’ gets created on S3 inside the bucket, but there is no other data or file in the bucket. The file contains the text ‘Permission Check Successful’.

This is my lambda function:

This is the response when I execute the lambda function:

Answer:

In fact, according to method create_export_task you should convert timestamp in milliseconds multiplying the resulted number by 1000 :

Also, make sure you have already created appropriate bucket policy to able your lambda to export and put objects on your bucket :

You try to create different folders on your bucket to make daily exports separated each other, it’s a brilliant idea:

But but it’s not possible to use timestamp on policy json, so you have to:

Change Resource Arn to this, to allow putObject on all newly created destination folders:

Leave a Reply