https://github.com/lily-g1/stop_start_instances
Automatically stop and start EC2 instances at scheduled times with Eventbridge + Lambda
https://github.com/lily-g1/stop_start_instances
aws cloud-services cost-optimization devops ec2 event-driven eventbridge iac infrastructure-as-code lambda-functions terraform
Last synced: 4 months ago
JSON representation
Automatically stop and start EC2 instances at scheduled times with Eventbridge + Lambda
- Host: GitHub
- URL: https://github.com/lily-g1/stop_start_instances
- Owner: Lily-G1
- Created: 2023-12-03T13:26:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-06T18:35:39.000Z (11 months ago)
- Last Synced: 2024-12-28T05:16:29.821Z (6 months ago)
- Topics: aws, cloud-services, cost-optimization, devops, ec2, event-driven, eventbridge, iac, infrastructure-as-code, lambda-functions, terraform
- Language: HCL
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stop_start_instances
## Automate the stop & start of EC2 instances to optimize costsThis code stops running instances at 5pm and starts them at 9am every weekday (Mon - Fri). Lambda runs the actual python functions that start and stop instances, while Eventbridge sets a schedule and triggers the Lambda functions at specified times. With an automation strategy such as this, you can effectively reduce AWS expenditure without compromise on performance or functionality.

## Prerequisites
- An AWS account
- Terraform installed on your local system
- One or more running AWS instances## To run:
- Clone this repo
- Enter root directory: ```cd stop_start_instances```
- Enter AWS instances' IDs in .py files
- Edit the cron expressions in eventbridge.tf to specify your time schedules
- ```terraform init```
- ```terraform plan```
- ```terraform apply```## To destroy:
- ```terraform destroy```