简体   繁体   中英

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.

Context: -Lambda execution role has permissions for CreateLogGroup, PutLogEvents, CreateLogStream, etc. for all resources. -Event type: ObjectCreatedByPut on a specific file name in an S3 bucket

Once I deploy the lambda, the first PUT trigger will successfully execute the lambda, and will also write to 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. The lambda will only write to CloudWatch logs if I redeploy the lambda code, and then upload a new version of the file.

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. I'm trying to understand if I am misunderstanding how the lambda triggers + deployment work together, or have I simply configured the lambda improperly?

Thanks!

Alright, I realized my error! Logging in CW Logs was occurring. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM