Many times, we have a lot of cloud waste because we never shut down our services/EC2 instances. One of the trickiest cases to control is the Auto Scaling Groups.
Now, this tutorial that is based on Vicent's one, I'm going to help you automate this task using AWS EventBridge and Lambda functions.
It's important to highlight that you must create two Lambda functions:
- One for stopping that is going to have a 0 as the environment variables (
MAX_SIZE
andDESIRED_CAPACITY
). - One for starting that is going to have 1+ as the environment variables (
MAX_SIZE
andDESIRED_CAPACITY
).
Now, the steps: