An EC2 machine is billed for the time it is running. A development, testing or office intranet server that is only used during working hours is running 168 hours a week and is used for maybe 50. Stopping it at night and at weekends cuts the compute part of its bill by more than half, without changing anything it does. This guide explains what you really save, what you don't, and how to schedule it so it happens on its own.
At the end we clear up the classic question: what about Lightsail? The short answer is that stopping a Lightsail machine saves nothing, and it is worth knowing why.
Before you start: what each thing means
- EC2
- Amazon's "made-to-measure" servers: you choose size, disk and everything else, and pay for the hours they are running. More flexible than Lightsail, with more things to decide.
- Instance
- What AWS calls each machine or server. Instance and machine are the same thing in this guide.
- Stop versus terminate
- Stopping is switching off: the machine and its disk are still there and it can be started again. Terminating is deleting it for good. This guide only stops.
- EBS disk
- The hard disk of the EC2 machine. It is charged separately from the machine and keeps being charged even when it is off, because your data is still stored.
- Elastic IP
- A fixed internet address you reserve and assign to your machine so it doesn't change when you stop and start. Without one, every start brings a different address.
- EventBridge Scheduler
- AWS's "alarm clock": a service that performs an action at the times you tell it, such as stopping or starting a machine, without you having to program anything.
- Cron
- The classic way of writing a repeating schedule in computing, with numbers separated by spaces (minute, hour, day...). The guide gives you the expressions ready-made.
- Lightsail
- The simple version of Amazon's servers, with a fixed monthly price. At the end of the guide we explain why stopping doesn't save money there.
Step by step
Understand what you stop paying and what you don't
When you stop an EC2 instance you stop paying for the instance's compute, which is the big part. You keep paying for:
- The EBS disk, because the data is still there. It is charged per GB per month whether the machine is running or not.
- The snapshots of that disk.
- The Elastic IP if you have one associated. AWS charges for public IPv4 addresses, and an Elastic IP assigned to a stopped machine is charged all the same.
If the machine carries an hourly licence (Windows, some Marketplace images), that part also stops when you stop it.
Check that the machine can cope with being stopped
Before automating anything, test it by hand: stop the instance from the EC2 console and start it again. Check three things: that the services start on their own when it boots (web, database, queues), that the machine keeps the same IP (only if it has an Elastic IP; without one, the public IP changes on every start) and that it doesn't use instance store storage, which is wiped when you stop. If any of this fails, fix it first.
Tag the machines that get stopped
In the EC2 console, select the instance, Tags tab, and add for example
Horario = oficina. It is not mandatory, but it lets you see at a glance which machines are part of the shutdown and, if you later use a scheduling tool, select them by tag instead of one by one.Create the shutdown schedule with EventBridge Scheduler
Open Amazon EventBridge, Scheduler menu, and click Create schedule. Give it a name (
apagar-dev-noche), choose Recurring schedule with a cron expression, for example0 20 ? * MON-FRI *for 20:00 Monday to Friday, and set the time zone to yours (Europe/Madrid) so that daylight saving changes don't throw you off.For the target, choose All APIs, search for EC2 and the StopInstances action. In the input box paste the machine's identifier:
{ "InstanceIds": ["i-0123456789abcdef0"] }Let EventBridge create a new execution role; it will give it exactly the permission to perform that action. Save.
Create the startup schedule
Repeat the previous step with the name
encender-dev-manana, cron0 7 ? * MON-FRI *and the StartInstances action, with the same identifier. If the machine takes a while to boot and people arrive at 8, set it to 7:30. Better a spare quarter of an hour than complaints.Keep an eye on it the first week
The next day look at the machine's tab: the "last state transition" should match your hours. In EventBridge Scheduler each schedule shows its last run and whether it failed. After a few weeks you will see the effect in Cost Explorer by filtering on that instance or on the tag.
Why stopping doesn't save money in Lightsail
Lightsail is not billed per hour of use but as a monthly bundle: so much a month for a machine of a certain size, including its disk, its IP and a transfer allowance. That bundle is charged for as long as the machine exists, running or stopped. AWS says so clearly in its documentation: stopped instances are still charged.
If you really want to stop paying for a Lightsail machine you don't use, the way is different: take a snapshot and delete the machine. You will pay only for the snapshot storage, which is much cheaper, and when you need it you create a new machine from it (there is a step-by-step guide in this same section). For a machine used every day during office hours, Lightsail is simply not the tool for saving money by stopping; either you accept the fixed price or you move it to EC2.
What can go wrong
The website changed IP on startup
You didn't have an Elastic IP. Allocate one from Elastic IPs in the EC2 console and associate it with the instance; from then on it keeps it across stops. Remember it is charged, but it is a small amount compared with the compute hours you save.
The services don't start on their own
On Linux, check that they are enabled at boot (systemctl enable nombre). On Windows, that the service is set to "Automatic". It is a problem with the machine, not with the shutdown, but the shutdown brings it to light.
The schedule doesn't run
Look at the schedule's execution role in EventBridge: it needs ec2:StopInstances and ec2:StartInstances permission on that instance. If you copied a role from another schedule, it may be missing one of the two actions. And check the time zone: if you left UTC, the schedule is off by one or two hours.
There are night-time jobs that no longer happen
Backups, reports, automatic updates at 3 in the morning... If the machine is off at that time, they don't happen. Move them into the running hours or, if they are heavy, leave them for a window when the machine is alive (for example start it at 6 and schedule the backup for 6:15).
In Simplio
In Simplio you start, stop and reboot your EC2 and Lightsail machines with a button, from your phone if need be, and each person on your team only sees the machines you have assigned to them. On the Costs screen you can see what each machine is costing you per month, to decide which ones are worth stopping. And if a machine that should be running shows up as stopped, it emails you.
The same task, in AWS and in Simplio
| In the AWS console | In Simplio | |
|---|---|---|
| Scheduling shutdown and startup | EventBridge Scheduler: 2 schedules, cron expressions, time zone, permissions role: 6 steps, 30 minutes | Start and stop with a button today; a per-machine schedule on one screen, in your time zone, when available |
| Knowing how much you save | Cost Explorer filtered by instance, the following month | Estimated monthly cost of each machine on the Costs screen |
| Finding out if it doesn't start | Also create a CloudWatch alarm | Email warning if a machine that should be running is stopped |