In 2026, cloud bills have become a top expense for most tech companies. One of the biggest "money-wasters" is leaving Development and Staging servers running over the weekend or at night when no one is using them.
If you have a t3.large instance running 24/7, you're paying for 168 hours a week. By shutting it down outside of 9-to-5 working hours, you can save over 65% on your monthly bill.
The Solution: "The DevSecOps Auto-Stop"
We will use a small Python script running on AWS Lambda that looks for a specific tag (like Schedule: OfficeHours) and shuts down any instance that shouldn't be running.
Step 1: Tag Your Instances
First, go to your AWS Console and add a tag to the instances you want to automate:
Key:
AutoStopValue:
True
Step 2: The Python Script (Boto3)
Create a new AWS Lambda function and paste this code. It uses the boto3 library to talk to your EC2 instances.
Step 3: Set the Schedule (EventBridge)
You don't want to run this manually.
Go to Amazon EventBridge.
Create a "Schedule."
Use a Cron expression to trigger the Lambda at 7:00 PM every evening:
cron(0 19 ? * MON-FRI *)
