简体   繁体   English

如何确保 Lambda function 在部署后的每个 S3 Put Trigger 上写入 Cloudwatch 日志?

[英]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.

相关问题 如何在CloudFormation中添加带有S3触发器的Lambda函数? - How do I add a Lambda Function with an S3 Trigger in CloudFormation? 设置为从 CloudTrail 触发的 CloudWatch 规则不会触发 Lambda function 除非我创建了一个跟踪来将 CloudTrail 日志存储在 S3 存储桶中 - CloudWatch Rule set to trigger from CloudTrail doesn't trigger Lambda function unless I create a Trail to store CloudTrail logs in an S3 bucket 每次我调用 S3 static 站点时,我如何触发 lambda function - How i trigger a lambda function every time I call a S3 static site 如何使用 aws cdk (JAVA) 每 15 分钟创建一个 cloudwatch 规则来触发 lambda function? - How can i create a cloudwatch rule to trigger a lambda function every 15 minutes using aws cdk (JAVA)? How to ensure that S3 upload triggers a lambda function, but copying data within the same bucket does not trigger the lambda function anymore? - How to ensure that S3 upload triggers a lambda function, but copying data within the same bucket does not trigger the lambda function anymore? 只有在 S3 上完成批量上传后,如何触发 AWS lambda 函数? - How do I trigger a AWS lambda function only if bulk upload finished on S3? 如何使用 AWS Lambda 通过 S3 触发 Comprehend? - How do I use AWS Lambda to trigger Comprehend with S3? 如何在多个 AWS Cloudwatch 日志流中查找 Python lambda function 的错误日志? - How do I find error logs for my Python lambda function across many AWS Cloudwatch log streams? 当我们从s3触发lambda函数时。 如何获取lambda被触发的日志。 我想用terraform做这个 - when we trigger lambda function from s3. how to get the logs that lambda is triggred or not. i want to do this with terraform 如何在lambda函数中添加s3触发器? - How to add s3 trigger to lambda function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM