Automated CloudWatch Logs Exports to Amazon S3 using AWS Lambda

Search for a command to run...

No comments yet. Be the first to comment.
🎬 The Story Picture this: You push code to GitHub. Five minutes later, your updated application is running in production—built, scanned for vulnerabilities, containerized, and deployed automatically. No manual steps. No human errors. Pure automation...
Building a Production-Ready GitOps CI/CD Pipeline: How Modern Companies Deploy Code 1000+ Times Per Day From Manual Deployments to Netflix-Level Automation 12 min read • DevOps • Cloud Native • Automation 🎯 The Problem Every Developer Faces Pictur...
When most people open VIM for the first time, the reaction is almost universal: “Why is this so confusing?” I felt the same—until I changed how I thought about it. VIM isn’t a typical text editor. It’s closer to cloud architecture than a traditional ...

If you're preparing for a Linux Administrator interview, here's a question you'll likely hear: "How do you patch Linux servers without internet access?" This is one of the most common interview questions, and for good reason – it's a real-world scena...

Introduction Have you ever encountered a "Permission denied" error while trying to access a file on Linux? Or wondered what those cryptic rwxr-xr-- characters mean when you run ls -l? Understanding Linux file permissions is fundamental to working wit...

In the realm of cloud computing, effective log management is essential. Amazon CloudWatch Logs offers centralized log storage, while AWS Lambda provides serverless computing capabilities. Combining these services enables the automated export of logs to Amazon S3, enhancing data durability and simplifying log management workflows. In this guide, we'll walk through setting up an AWS Lambda function to streamline the process of exporting CloudWatch Logs to an S3 bucket, offering a scalable and efficient solution for organizations seeking improved log data management in the AWS ecosystem.
GitHub Repo: https://github.com/saadkhan024/Cloudwatchlogs-to-S3bucket
We need to create a lambda function which will invoke with Cloudawatch

You can select create new role as i am doing for testing purpose.

We will write some dummy function to test the case.
This is my Test function code

You can see that after executing it run successfully.

For checking the logs has been created or not, go to CloudWatch and check on Logs group.

Log has been generated.

For sending the logs from cloudwatch to s3 we will require IAM role.

and we will select the given policy and edit the trust policy.


We will setup the lambda function with attaching the IAM role which we have created.

We need to change some default configuration time to 15 min of highest.


Now we have to change the lambda function with our customized code and deploy.
you can find the code in my github repo.

Go to search bar and type S3 and click on create and put the info.

We will edit the policy under s3 with our inline policy you can find the same on github repo.

After deploying the script you can see that logs has been generated.
Thank You...