[英]How do I ensure that a Lambda function writes to Cloudwatch Logs on every S3 Put Trigger after deploy?
Problem: My lambda function only writes to CloudWatch Logs on the first S3 PUT trigger after deploy.问题:我的 lambda function 仅在部署后的第一个 S3 PUT 触发器上写入 CloudWatch Logs。
Context: -Lambda execution role has permissions for CreateLogGroup, PutLogEvents, CreateLogStream, etc. for all resources.上下文:-Lambda 执行角色对所有资源具有 CreateLogGroup、PutLogEvents、CreateLogStream 等权限。 -Event type: ObjectCreatedByPut on a specific file name in an S3 bucket
-事件类型:S3 存储桶中特定文件名的 ObjectCreatedByPut
Once I deploy the lambda, the first PUT trigger will successfully execute the lambda, and will also write to CloudWatch Logs.部署 lambda 后,第一个 PUT 触发器将成功执行 lambda,并且还将写入 CloudWatch Logs。 All subsequent PUT actions (uploading a new version of the file) will also successfully execute the lambda, however, it will not write to CloudWatch Logs.
所有后续 PUT 操作(上传文件的新版本)也将成功执行 lambda,但是,它不会写入 CloudWatch Logs。 The lambda will only write to CloudWatch logs if I redeploy the lambda code, and then upload a new version of the file.
如果我重新部署 lambda 代码,然后上传新版本的文件,lambda 只会写入 CloudWatch 日志。
My assumption is that I would only want to deploy the code once, and then every PUT trigger that occurs after deployment would both execute the lambda and write logs to CW Logs.我的假设是我只想部署一次代码,然后部署后发生的每个 PUT 触发器都将执行 lambda 并将日志写入 CW 日志。 I'm trying to understand if I am misunderstanding how the lambda triggers + deployment work together, or have I simply configured the lambda improperly?
我想了解我是否误解了 lambda 触发器 + 部署如何协同工作,或者我只是不正确地配置了 lambda?
Thanks!谢谢!
Alright, I realized my error!好吧,我意识到我的错误了! Logging in CW Logs was occurring.
正在登录 CW 日志。 I simply didn't realize that all PUT trigger events within the same deploy would be logged within the same log stream, while put trigger events part of different deploys would be logged in a separate log stream (what I was expecting in both cases).
我根本没有意识到同一部署中的所有 PUT 触发事件都将记录在同一日志 stream 中,而不同部署的部分触发事件将记录在单独的日志 stream 中(这两种情况都是我所期待的)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.