Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-06T18:35:39.000Z (6 months ago)
- Last Synced: 2024-11-07T11:47:12.339Z (3 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.
![stop_start drawio (1)](https://github.com/Lily-G1/stop_start_instances/assets/104821662/2e0feeee-50d1-45ea-8b51-89d0af1252d2)
## 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```