Home>

I would like to ask you a question about the behavior of Lambda on AWS.

This is the person who asked me a question on stackoverflow a while ago. (https://www.tutorialfor.com/go.php?id=303166 )

I am currently using Route53 on AWS, collecting query logs with CloudWatch Logs, running a program using python with lambda on a regular basis, and transferring query logs from CloudWatch Logs to S3.

It's a little related to what I asked you last time, but on Lambda
client = boto3.client ('logs')
response = client.create_export_task (
)
I have a question about the behavior when I execute.

I'm currently running this function at 0:10 every day and set the timeout to 30 seconds.
The execution log of the function is also saved in CloudWatch Logs, and if you check that, you can see that the duration is about 15 seconds at the longest, so it is operating stably.
However, if you check the save time of S3, there are some that are saved at 0:13 etc. if it is slow.

I'd like to ask, "Why does it happen that the function is saved in S3 after it finishes executing?"
My perception was that the transfer from CloudWatch Logs to S3 was taking place while the Lambda function was running. Therefore, I think it is impossible that the save time recorded in S3 is outside the execution time.

Is this perception wrong?
I don't know how Lambda works, so it may be a question that doesn't make sense, but if you have any details, please answer.

  • Answer # 1

    My perception was that the transfer from CloudWatch Logs to S3 was taking place while the Lambda function was running.

    I don't think this fits the content below. Since the create start task is like an asynchronous call, it is likely that the export is not finished at that moment even if the call is successful.

    https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateExportTask.html

    This is an asynchronous call. If all the required information is provided, this operation initiates an export task and responds with the ID of the task. After the task has started, you can use DescribeExportTasks to get the status of the export task. can only have one active (RUNNING or PENDING) export task at a time. To cancel an export task, use CancelExportTask.