[英]Send line from file each time Lambda function is triggered [python]
I have search about this issue and couldn't find anything that would help me.我搜索了这个问题,但找不到任何对我有帮助的东西。
EDITED已编辑
The main idea is to, each time the lambda function is triggered by cloudwatch (everyday), choose a subsequent line from the text file that I get from a s3 bucket, that line will be attached to an e-mail.主要思想是,每次 lambda function 由 cloudwatch(每天)触发时,从我从 s3 存储桶获取的文本文件中选择后续行,该行将附加到电子邮件中。 The next time the lambda is triggered, the same will happen, but with the next line in the text file, and so on.下次触发 lambda 时,同样会发生,但文本文件中的下一行,依此类推。
I have more or less an idea, using a for loop, my problem is how to, each time the function is triggered, select the next line in the text file.我或多或少有一个想法,使用 for 循环,我的问题是每次触发 function 时,文本文件中的下一行 select。
If you need to read lines from your file in sequence, one lambda execution a day is one line, then you have to keep track of those lines .如果您需要按顺序从您的文件中读取行,每天执行一次 lambda 就是一行,那么您必须跟踪这些行。 If its only once a day, you could use SSM Parameter Store for that.如果它每天只有一次,您可以为此使用 SSM Parameter Store。 Each time your lambda executes, it would query SSM Parameter Store the the line number which was read previously.每次执行 lambda 时,它都会查询 SSM Parameter Store 之前读取的行号。
Similarly, after successful dispatch of a line, the Lambda function would update the parameter in SSM Parameter Store.同样,线路调度成功后,Lambda function 将更新 SSM Parameter Store 中的参数。
The exact details depend on how big the file is, as this process can get progressively slow with time.确切的细节取决于文件有多大,因为这个过程会随着时间的推移而逐渐变慢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.