Chapter 5: Amazon EC2 (Elastic Compute Cloud)
5.6 Instance lifecycle: stop, reboot, hibernate, terminate
Pay attention – this table decides whether your data stays or goes, and whether the bill keeps running or stops. Read it twice, friends.
ध्यान रखो – हा टेबल ठरवतो की तुमचा डेटा राहणार का जाणार, आणि बिल चालू राहणार का बंद होणार. दोन वेळा वाचा, मित्रांनो.
ध्यान रखो – यह टेबल तय करता है कि आपका डेटा रहेगा या जाएगा, और बिल चलता रहेगा या बंद होगा. दो बार पढ़ो, दोस्तों.
pending ──► running ──► stopping ──► stopped ──► (start) ──► pending
│ ▲
reboot │ │
▼ │
running ──► shutting-down ──► terminated (gone for ever)
| Action | What happens | Public IP | EBS root volume | Billing |
|---|---|---|---|---|
| Reboot | The operating system restarts on the same instance and ordinarily on the same host. | Kept | Kept | Continues |
| Stop | Instance shut down; may move to new host on start | Ordinary auto-assigned public IPv4 is released. A new one may be assigned after start. The intended EIP association can remain. | Kept | Ordinary running compute usage stops. Retained EBS and allocated public IPv4 have separate charges under the applicable terms. |
| Hibernate | On a supported, configured instance, memory is saved to the encrypted EBS root volume and then the instance stops. | Ordinary auto-assigned public IPv4 is released. The intended EIP association can remain. | Kept | Unlike a normal stop, compute is billed while stopping for hibernation. Retained storage and allocations have their own charges. |
| Terminate | Instance deleted permanently | Ordinary public assignment ends. An Elastic IP allocation can remain in the account. | Deleted if Delete on termination = yes (default for root) | Compute ends. Retained EBS volumes, snapshots and allocated addresses can still incur charges. |
In simple words: stop is like closing your shop and keeping the key in your pocket – the goods on EBS stay inside and storage charges keep running. Instance-store data is temporary and is lost when EC2 stops. Terminate is like handing back the shop. You cannot start that instance again. A volume with Delete on termination enabled is deleted, while retained volumes and snapshots stay in the account until you remove them. For Mauli Dairy's live server, the owner can use termination protection for covered requests. Check its limitations and verify data recovery separately.
सोप्या भाषेत: stop म्हणजे दुकान बंद करून चावी खिशात ठेवा – सामान (डेटा) आत सुरक्षित आहे, पण जागेचं भाडं (EBS चार्जेस) चालू राहतं. Terminate म्हणजे दुकान पूर्ण खाली करून परत देणं – प्रत्येक EBS volume टिकेल की delete होईल हे त्याच्या Delete on termination setting वर अवलंबून आहे. Mauli Dairy च्या live server साठी termination protection काही विनंत्या रोखू शकतं. Backup आणि restore वेगळे पडताळा.
आसान भाषा में: stop मतलब दुकान बंद करके चाबी जेब में रखना – सामान (डेटा) अंदर सुरक्षित है, लेकिन जगह का किराया (EBS चार्जेस) चलता रहता है. Terminate मतलब दुकान पूरी खाली करके वापस दे देना – हर EBS volume रहेगा या delete होगा, यह उसकी Delete on termination setting पर निर्भर है। Mauli Dairy के live server पर termination protection कुछ अनुरोध रोक सकता है। Backup और restore अलग से जाँचो।
Terminate is permanent
A terminated instance cannot be started again. Termination protection blocks covered manual requests and has documented limits. For important workloads, verify a recovery plan and relevant retained data before making changes.
Ravindra Bagale's Tip
Ordinary running compute usage stops after a supported stop. Retained EBS and allocated Elastic IP resources can still incur charges. At the end of an approved lab, verify only the volumes and addresses that the lab owns and remove them only if the cleanup plan allows.
Ravindra Bagale's Tip – मराठी
Instance stop झाल्यावर चालू compute चा वापर थांबतो. Retained EBS आणि allocated Elastic IP चा खर्च अजून होऊ शकतो. Lab संपल्यावर फक्त या लॅबचे volumes आणि addresses तपासा आणि मंजूर cleanup प्रमाणेच काढा.
Ravindra Bagale's Tip – हिंदी
Instance stop होने पर चल रहे compute का उपयोग रुकता है। Retained EBS और allocated Elastic IP पर शुल्क जारी रह सकता है। Lab पूरी होने पर केवल अपनी लैब के volumes और addresses की जाँच करो और स्वीकृत cleanup के अनुसार ही हटाओ।
Lab
For a disposable instance you are allowed to operate, compare reboot and stop/start using the same instance ID, relevant address associations and an EBS-backed marker. Read termination protection and volume retention separately in the console. Use the verification and cleanup worksheet below. Do not submit a termination just to test protection.
Start by identifying what needs to survive the operation
Mauli's demonstration server has finished serving class. One operator wants to restart the operating system. Another wants to pause the lab so the running compute state ends. A third wants to remove the instance and keep the sample records. Those intentions lead to different EC2 operations. Before making a change, write down what should happen to the process, memory, files, IP assignments and billable resources. A label such as restart can mean either a reboot or a stop followed by start, which behave differently.
Use two inventories. One lists what belongs to the instance today: current state, Region, ID, interfaces, addresses, volumes, software and dependencies. The other lists what must remain after the change: business records, approved backups or images, service name, permitted identity and any needed billing allocations. That separation helps you determine whether an operation meets the goal. Removing a machine is irrelevant if the actual task was to free one temporary storage resource or restart one app process.
In the standard exercise, the instance boots from an Amazon EBS volume. EBS is block storage that has its own lifetime. An ordinary stop can leave that volume attached and intact even though the instance is no longer running. Some types also offer instance store, which is temporary host storage with its own loss conditions. A backup or recovery test is separate. A volume preserved after stop can still contain the wrong or damaged file.
Use an approved disposable training instance if you practice a live operation. Record which owners and applications may depend on it, limit any test to your own lab resources and prepare a rollback or recovery plan for the operation chosen. Nothing in the paper exercise requires you to stop a customer system, modify a shared network or terminate an instance just to find out what a setting does.
Watch state transitions and service readiness independently
EC2 uses instance states such as pending, running, stopping, stopped, shutting-down and terminated. An accepted launch or start moves through pending before the instance can run. An accepted stop can move through stopping and later stopped. Termination moves through shutting-down and leads to terminated. Those values describe the EC2 resource lifecycle. They do not report whether the guest process has initialized, whether someone can log in or whether an application request succeeds.
| Observation | What it establishes | What to verify before using the application |
|---|---|---|
pending | EC2 is preparing the resource to run. | Wait for the intended state, then inspect the applicable checks and boot results. |
running | The instance is in its running lifecycle phase. | Verify relevant EC2 checks, guest and application readiness from intended clients. |
stopping or stopped | The resource is stopping or has finished stopping. | The application is not serving from the stopped instance. Inspect retained data and addresses separately. |
shutting-down or terminated | The instance is being removed or cannot run again as that instance. | Verify volume and address behavior and the planned service replacement or final cleanup. |
A reboot is an operating system restart, and the EC2 lifecycle can continue to show running while the guest reboots. A shell connection closes and app requests can fail temporarily even though the state name still says running. Check which operation you requested and whether the same instance is in use. A software restart may restart one process without a full operating system reboot. Select the smallest appropriate operation in the approved maintenance plan.
Cloud operations can return an acknowledgement before the state has finished changing. For a training exercise, poll the console or permitted status view at reasonable intervals and wait for the operation's expected stage. A repeated click can start an unintended request or obscure which one succeeded. If the transition stays incomplete, read the status and service's explanation before using another action. Abrupt force actions have different consequences for the guest and its files. Handle a production request under its owner's change and incident procedure.
Use a reboot to restart the operating system on the same resource
Imagine the teaching guest needs to load a new kernel after an authorized software maintenance window. Reboot restarts its operating system on the same instance and ordinarily on the same host, unless other AWS events affect placement. The private address, ordinary public address and Elastic IP associations ordinarily remain. EBS volumes remain attached, and instance store survives an ordinary reboot under the conditions AWS documents. Processes and their ordinary working memory are lost and have to start again.
The most obvious change for a student is that a logged-in shell breaks. Before requesting the reboot, finish or safely stop operations that should not be interrupted. A long file copy or app update may need to complete first. Verify that the intended service starts after reboot according to the approved configuration. Running a foreground command in one shell does not necessarily arrange for the system to start it on the next boot.
In a production rollout, make sure the statement “we can reboot it” names who can serve users while it is unavailable. If a fleet uses a load balancer, the owner can apply a planned process that verifies remaining capacity, removes or drains one target as appropriate, then tests it before serving new requests. If Mauli's demo has only one instance, expect a visible break during restart. Stable IP values let the client return to the same intended path after it becomes ready, but do not hide the downtime.
After the operation verify the current instance ID, intended address and actual operating system evidence. On a supported Linux guest the reported boot identifier can distinguish two boot cycles of the same instance. The application test should be specific. A useful result for the training prototype is status 200 and the sample text from the planned listener. A cloud running status is earlier evidence and not a substitute for that result.
Stop and start the same EBS-backed instance when you need a longer pause
Stopping an EBS-backed instance shuts down its running guest and leaves a stopped instance resource you can later start. Its compute placement may change when started. The original instance ID and EBS volumes ordinarily remain. Process memory from an ordinary stop is gone, and temporary instance store content is not retained. The application must be able to restart from durable state. Stop is not available for every type of backing or operational state, so use the service documentation for your instance.
The ordinary primary private IPv4 remains in the same-instance example. An auto-assigned public IPv4 is released on stop and can be replaced on start. An associated Elastic IP can remain associated according to the configuration. If you use DNS or a saved public host address, check that it still refers to the intended endpoint after start. In a private-only lab direct public address is not expected. The approved private access method needs to continue meeting its prerequisites.
Check retained resources and any services that rely on the paused instance. An ordinary stopped instance is not providing compute cycles to the guest. It can still hold storage and an allocated public address. A frontend or gateway may remain in service even if the test instance stopped. These states have different billing implications. Application jobs running elsewhere can also rely on the instance and need an approved pause or handoff. Avoid treating a stopped state as completion of the entire maintenance plan.
Starting a shutdown from the guest can have a configured EC2 shutdown behavior. In an EBS-backed design, check the instance-initiated shutdown attribute before assuming a command run inside the operating system has the same effect as an ordinary Stop request in the console. Some configurations terminate on a guest-initiated shutdown. Record the intended workflow and who can initiate it. This distinction is especially useful when an application offers its own shutdown control or an administrator works from a remote shell.
Normal guest shutdown gives processes a chance to finish under their configured shutdown procedures. Force or skip-shutdown controls can interrupt that behavior and risk unwritten data. If an authorized instance appears stuck, inspect the service state and use the owner’s approved recovery process before considering an abrupt action. Write down which storage and application state must be checked afterward. An apparent shortcut that makes a console transition complete can still leave the guest or its files needing recovery.
When starting again, review the allowed account and resource, observe the running state and applicable checks, then verify boot and application status. Read the actual startup logs under the approved scope if the service has not initialized. A one-time user data script does not ordinarily rerun as a fresh install on every start or reboot. Your app can need a properly configured service startup mechanism. A successful state transition does not establish that the app restarts automatically.
Use hibernation only when the instance and workload support it
Hibernation saves the guest's RAM contents to its EBS root volume and stops the instance. Starting the hibernated instance can reload that state and resume processes under supported conditions. This is different from an ordinary stop, where process memory is lost and the guest boots afresh. The feature is useful for suitable workloads that take time to initialize their in-memory environment. It is not an alternative to saving authoritative data in durable storage.
A hibernation plan must meet the documented prerequisites at launch. Check supported instance type, operating system and AMI, root EBS capacity and encryption, and provisioning settings. The root volume must have room for the memory contents and other required data. Encryption matters because RAM can contain sensitive operating state. Requirements and supported types change. Use AWS's current documentation rather than relying on a static list or copying a setting from another instance. If the mode was not configured or the usage is unsupported, evaluate an ordinary stop and restart or a workload-level checkpoint.
Imagine a training data processing worker has built an index in memory. A hibernate/resume test can determine whether the intended operation continues under that app's design. A different process may hold a connection to an external database or vendor. That remote server may have closed the connection while the worker was suspended. The fact that the local process resumes does not mean the other end of each connection remains active. Application verification includes reconnect and required timing behavior.
AWS bills compute while an instance is stopping due to hibernation under its documented lifecycle billing, unlike the ordinary stopping state. Compute usage charges stop once the instance is stopped, subject to the applicable purchasing and billing terms. The retained root volume and other storage continue with their own cost model. Check the current billing rules and the amount of storage selected to support hibernation. A successfully resumed process still needs to prove the observed work, security and recovery requirements.
Terminate only an identified instance and verify what its volumes will do
Termination ends the instance resource permanently. You cannot start the same terminated instance ID again. To restore service, you need a separately prepared image, deployment configuration, application and durable data depending on the workload. An EBS-backed instance usually has a root volume configured to be deleted on termination by default. The selected configuration can override that, and other volumes can have their own DeleteOnTermination settings. Read all relevant device mappings before an authorized termination.
A retained EBS volume can outlive its instance and may continue to incur charges. A snapshot, allocated Elastic IP, load balancer or NAT gateway may also survive depending on ownership and configuration. Inventory each relevant object independently. The cleanup success condition is that the expected resources are gone or intentionally retained. It is rarely that a Region or account has no remaining resources at all. Shared classes, recovery teams and other applications can have their own correct allocations there.
Termination protection helps against certain manual API or console termination requests. It has documented limitations. For example, ask whether an Auto Scaling process or an instance-initiated shutdown behavior can terminate the machine under a different policy. Stop protection and scale-in protection are other controls with their own scope. A protection setting cannot recover a file, recreate a lost volume or replace the need to test approved recovery. Use it with access control and an explicit change workflow rather than as a guarantee.
Suppose the last instructor says an old practice worker can be removed if its sample data is archived. Ask which volume or service actually holds those records. Verify that the archive can restore the approved records in a safe test. Then establish the instance ID, region, volume settings and which public names or attachments still refer to it. When cleanup is authorized, verify the result against that plan without changing unrelated resources or disabling anyone else's safeguards.
Read the resource bill at each stage of the lifecycle
In an ordinary On-Demand exercise compute use is billed under the selected pricing rules while the instance runs. A standard stop ends running compute after the transition under the applicable rules. Hibernation has the documented exception during stopping, when the guest state is being saved. A stopped instance can retain EBS volumes and an allocated public IPv4. A reservation or purchase commitment, software charge or other associated service can have rules independent of the running-state count.
A useful worksheet lists compute time, storage held, public IPv4 allocation, monitoring or snapshot use, and supporting network services. Take a 24-hour illustration: the worker runs four hours and remains stopped for twenty. The worksheet records four worker-hours before the applicable billing granularity, one EBS volume held for the full period, and separate time for any address the account retains. If one allocated EIP stays attached through the stop, its period is not equal to the worker's four running hours. The monitoring and storage retain their own units and rates.
Now suppose the worker was one target of an existing load balancer shared by two training apps. Stopping or terminating the target does not delete that load balancer. It may be needed for the second app. Record the shared service's existence and approved ownership rather than issuing a cleanup action against it. Other resources such as a NAT gateway or a test route can also remain. Identify which ones the lesson created and which were already present.
Check account eligibility and credits if the lab relies on them. AWS Free Tier terms depend on when the account was created and the applied plan or legacy eligibility. Test cost assumptions using the account's current terms and service pricing. An alert can signal changes. Resource inventory and billing updates can arrive on different schedules, so record the actual state evidence and check later billing according to the account's procedure. Avoid claiming all charges ended because the instance list changed.
Compare a reboot and a stop using observations from one authorized guest
The full exercise needs an instructor-approved disposable EBS-backed Linux instance, a permitted management path and approval to reboot and stop or start that particular resource. Confirm the expected volume behind your test file. The guest home directory in this example is on the intended EBS-backed storage. If the actual account uses a different mount layout or temporary storage, inspect it through the approved view and use only the allowed EBS-backed test path. Anyone without the appropriate lab can answer the paper version below.
Record the instance ID or agreed alias, approved subnet, private IPv4 and any ordinary public or Elastic IP association. Write whether the chosen access uses a direct public endpoint or approved private path. In the guest record the hostname and, on supported Linux, the boot ID. These values help distinguish the same guest before and after a transition.
Create a unique sample file in the authorized test user's own EBS-backed home directory. Record its printed path so you can use the same file after reconnecting. Run this only on the disposable worker selected for the lesson.
hostname cat /proc/sys/kernel/random/boot_id LAB_MARKER=$(mktemp "$HOME/mauli-lifecycle.XXXXXX") || exit 1 printf '%s\n' 'Mauli lifecycle training marker' > "$LAB_MARKER" printf 'Training marker path: %s\n' "$LAB_MARKER" cat "$LAB_MARKER"End the current session and perform the approved reboot from the account interface. The instance may continue reporting running. Wait for the intended guest access and readiness. Reconnect to the current approved endpoint and read the boot ID and the specific recorded marker. The boot ID should differ after the ordinary guest boot, while the marker remains under its EBS storage. An ordinary reboot preserves the address association in this exercise.
Under the approved lab plan, stop and start the same instance. Wait for stopped before starting, then for expected running and guest readiness. If it has an auto-assigned public IPv4, read the current association before reconnecting. Confirm the private IPv4 and that the marker on the EBS filesystem remains. If the instance uses an intentional Elastic IP or is private-only, record that case rather than expecting an auto public IP change.
Verify one relevant guest or application operation from the intended path. An operating system boot ID changes when a new Linux boot occurs. It does not tell you whether the web service started, or whether the saved data is the expected version. The sample marker is a file check and not a backup verification.
For the paper version, assume a Linux boot ID differs after ordinary reboot and again after stop and start, the same instance ID remains, and the sample file contents are unchanged. The original auto-assigned public IPv4 is retained on reboot and replaced on start in this example. Explain which observed change you would check first if the student used an old public bookmark. If your actual test differs, confirm the operation, guest and storage path before adjusting expectations. Remove only the exact marker you created and handle the disposable resource under the approved cleanup plan.
Read the state and volume settings before a cleanup decision
This exercise requires AWS CLI read permissions to one approved existing training instance, or the equivalent console access. It does not stop, restart or terminate any resource. Replace the placeholders before running it and protect the returned identifiers according to the lab's policies. Choose the resource by exact identifier and known account and Region.
LAB_PROFILE='REPLACE_WITH_TRAINING_PROFILE'
LAB_REGION='REPLACE_WITH_TRAINING_REGION'
LAB_INSTANCE='REPLACE_WITH_TRAINING_INSTANCE_ID'
aws ec2 describe-instances \
--profile "$LAB_PROFILE" --region "$LAB_REGION" \
--instance-ids "$LAB_INSTANCE" \
--query 'Reservations[].Instances[].{State:State.Name,Root:RootDeviceName,HibernateConfigured:HibernationOptions.Configured,Devices:BlockDeviceMappings[].{Device:DeviceName,Volume:Ebs.VolumeId,DeleteOnTermination:Ebs.DeleteOnTermination}}' \
--output json
aws ec2 describe-instance-attribute \
--profile "$LAB_PROFILE" --region "$LAB_REGION" \
--instance-id "$LAB_INSTANCE" --attribute disableApiTermination \
--query 'DisableApiTermination.Value' --output json
The first command shows lifecycle state, root device name, hibernation configuration when returned and the mapped device-level EBS flags. Match the root device name to the corresponding record. The root volume might show deletion enabled while another data volume is retained. The second command reads the termination protection attribute. A true result means the setting is enabled, subject to the documented limitations. It does not authorize testing a termination against the resource.
Practice with three example results. The root mapping has deletion enabled, an extra data volume has deletion disabled, and protection is enabled. A normal authorized console termination request would be blocked in the relevant case unless the owner changes that setting. If the instance were later terminated through an authorized supported workflow, the device flags would guide what AWS should retain for those volumes. The extra volume can be retained intentionally or removed later by its owner after the lab's plan verifies recovery and need.
If the CLI does not return a row or permission is lacking, check the scope and current permissions. Do not choose another instance because its values happen to appear. In a real cleanup check record the known volume and address identifiers, whether they still exist and who owns them. The read-only inspection leaves everything as it was. For a worksheet only, record the predicted outcomes and which check would establish them afterward.
Diagnose a failed restart without confusing it with a failed service
Mauli's instructor presses Start, and the instance eventually reports running. The public page still fails. Compare the current record with the last verified values before changing routes. A stopped and started instance may have received a different ordinary public IPv4. The frontend name can be using an earlier record. Or the private host can accept the approved guest connection but the application can be absent because the course server was originally started manually. A usable diagnosis identifies the first observation that differs.
Use the actual failing operation to organize the evidence. If the EBS-backed instance never becomes running, inspect the service state reason, allocation capacity and the account's permissions. If the guest becomes reachable but the filesystem doesn't show the expected data, verify which device and mount the app actually uses. Data originally in memory or temporary instance store behaves differently from a durable volume. If the app responds with a wrong result, compare its startup configuration, name and dependency identity. Repeating a restart can obscure those details.
A hibernated application may resume but need to reconnect external sessions. Check the actual recorded mode and what AWS reported. Even where hibernation was configured, its behavior can fail under specific conditions documented for the operating system or instance. A meaningful test reads or resumes a permitted sample operation and verifies the expected result. If important state was only held in memory, understand the checkpoint or backup plan before attempting any forced shutdown.
When reporting the issue write the action, region and approved identifier, observed state, guest and address result, and first missing service outcome. If an allowed correction is made, repeat the same service test. If the activity was merely a classroom exercise, leave the approved protected infrastructure and other students' resources intact. Termination belongs to a controlled ending, rather than a troubleshooting test applied to a machine you may still need.
Recover a known application state instead of assuming a disk is a backup
An EBS volume keeps whatever bytes are on it at the relevant time. Suppose Mauli writes order records to a database on an attached volume. One user submits an order and its transaction is committed. Another request is still partly processed while a stop is initiated. A normal guest shutdown under supported conditions can let applications complete their shutdown sequence. A disconnected client may still be unsure whether its request committed. The application needs its own way to verify the record, such as a unique order identifier and a checked status. Compute state does not describe which business operations completed.
Decide which consistency the recovery plan needs. A training snapshot may capture a storage point suitable for a test restore. Some workloads require coordinating writes or using a service-aware backup mechanism to capture several related files or volumes in a consistent way. AWS documents the timing of EBS snapshots and guidance for mounted and root volumes. Inspect those requirements before creating backups of important data. A backup process should avoid assuming that a background command copied all unflushed application state.
To test recovery, write the expected record first, the recovery source and the allowed target environment. Restore an approved copy into a disposable destination separate from the live system. Verify the intended records or file integrity and run one synthetic transaction that demonstrates the required service. A successfully created snapshot says that a storage operation completed. A successful test restore demonstrates that the approved copies can actually recover the specified data or operation. Both results have value, and the second is closer to the owner's requirement.
Do not start an old training instance merely to recover a file if the approved data is already archived elsewhere. Compare the expected point in time and the data ownership first. A stopped instance can contain outdated access credentials, packages or private material. Recovery should use the approved environment and access controls. Keep the live application connected to the authoritative data while training tests run against copies.
Check whether an automation owns the instance before pausing it
Mauli's delivery worker belongs to an EC2 Auto Scaling group that manages its number of useful workers. An operator sees an instance and thinks stopping it for a few hours will save its compute cost. However, the group's job can include maintaining its desired capacity and replacing instances that do not meet its health conditions. Manually stopping a member can trigger an automation response rather than leaving the desired group one worker smaller. Confirm who owns lifecycle decisions for the instance before changing its state.
A planned maintenance action can use an Auto Scaling mechanism such as an approved Standby workflow where applicable. AWS describes the behavior of moving an instance into Standby, including what happens to load balancer registration and group capacity according to your choice. Decide whether the group should launch replacement capacity while maintenance is underway. Keeping track of desired, in-service and standby counts is more informative than assuming an instance state alone describes a fleet. A group definition, a launch configuration and the guest's application all contribute to actual capacity.
Consider a fleet with two healthy targets and one maintenance case. Leaving only one active target may be fine during a low-demand training session, but could violate an agreed capacity or redundancy requirement during a real release. Before maintenance the owner should verify headroom and the planned route from the user. After maintenance verify the replacement or returned target receives its intended requests and reports appropriate health. An application routed through a frontend needs both target readiness and the customer's actual response to be verified.
Scope lifecycle safeguards and recovery to the managing system. An instance's manual termination protection can protect covered requests; it does not substitute for the Auto Scaling group's own lifecycle criteria. Scale-in protection also has documented limits and does not make a host permanent against every replacement case. A robust app worker can often be recreated from an approved launch record while business state survives outside its temporary local process. Identify what the group will replace and what must be maintained separately.
Run a paper-safe state, address and billing comparison
This model needs Python 3 or a spreadsheet. It measures simplified minutes of running compute, minutes an independent EIP is allocated and whether the example lease keeps a data volume. It has no AWS access and does not represent a price quote or every purchasing option. Treat hibernation's saving phase as billable compute time for this exercise, and a plain stop's ordinary stopping phase as no modeled compute use. Record each resource's lifetime separately.
python3 - <<'PY'
cases = [
("ordinary stop", 40, 0, 120, "kept"),
("hibernate", 40, 3, 120, "kept"),
("terminate with data volume retained", 40, 0, 90, "retained"),
]
for action, running, hibernating, allocated, volume in cases:
print(f"{action}: compute {running + hibernating} min, "
f"address {allocated} min, data {volume}")
PY
Expect ordinary stop to show 40 modeled compute minutes and 120 held address minutes. Hibernation shows 43 modeled compute minutes because the three-minute save phase is included. The terminated case shows 40 compute minutes and 90 held address minutes under the supplied separate address plan. It retains the data volume according to the chosen deletion flag. Each value is an input assumption or a simple sum. The model does not know the account's actual rates, elapsed times or remaining services.
Change the third scenario so the address remains allocated for 120 minutes. Explain why the instance termination row can stay at 40 compute minutes while the address duration changes. Add a column stating the expected fate of an ordinary primary private IPv4 and sample process. The terminated resource cannot keep serving, while a retained volume can give a replacement a path to data under an approved recovery plan. This exercise separates those decisions. The code creates no resources and writes no files.
Practice predicting resource outcomes and proving them afterward
Choose a lifecycle action for three needs: activated kernel update, an overnight pause of an EBS-backed class server, and permanently removing a used test worker. For each explain what happens to process state, files and public association under the selected configuration. State which user-facing check resumes after each reversible action.
Plan a hibernation evaluation for an eligible data worker that holds an in-memory index. Identify launch prerequisites, what gets stored on the encrypted root volume and how you will verify a connection lost over the pause. Include one case where an application-level checkpoint would be more appropriate.
Create a resource ledger for a root EBS volume marked for deletion, a retained data volume, a snapshot and an EIP created for the lab. Write what ordinary stop and authorized termination do to each, and which items continue to need a billing or retention decision.
Review an Auto Scaling design in which a colleague says termination protection is sufficient to prevent replacement. Explain the scope of the relevant controls. Describe the required data durability and app readiness checks for any worker that the deployment may replace.
Interview questions and worked answers
Does a reboot move an EC2 instance through stopped and pending?
A guest reboot normally stays on the same EC2 instance and does not use the ordinary stop and start lifecycle. The EC2 state can remain running while the guest restarts. Address and disk assignments usually remain, while process memory is cleared and connections are interrupted.
Why can an EBS-backed instance retain files after ordinary stop?
EBS block storage has a separate assignment and lifetime from the running guest. The volume can remain attached while the instance is stopped. Instance store needs different handling and ordinary stop can lose it. Verify the real volume and do not equate retention with recoverability.
What does hibernation preserve that ordinary stop does not?
It saves the guest's memory state to the supported encrypted root EBS volume so it can be restored on start. The instance and image must meet current prerequisites. Remote systems can have closed old connections and application recovery still needs to be checked.
When do stopped instances still have costs?
A stopped instance can retain EBS volumes, snapshots and allocated public addresses. Supporting services or purchase commitments can also remain under their own rules. Check which resources are allocated and which billing terms apply instead of evaluating the running state alone.
Can I recover a terminated instance by starting its EBS volume?
The terminated instance cannot be started as the same resource. A retained volume or approved snapshot may help prepare a new instance under a recovery plan. Verify the fresh machine, intended data and application operation. Termination protection alone is not a backup.
Check what changes in each lifecycle action
Which operation can restart the guest while EC2 still reports running? A. Ordinary reboot. B. Permanent termination. C. Releasing an Elastic IP alone.
Show answer
A. Reboot restarts the guest without an ordinary stop and start sequence. Existing sessions can break while the operating system is restarting. Check guest readiness separately from the running state.
An ordinary EBS-backed worker stops and starts. What can change? A. Its ordinary auto-assigned public IPv4. B. Its instance ID by definition. C. Every EBS-backed file by definition.
Show answer
A. EC2 can release the original auto-assigned public address on stop and associate a new one on start. The same resource and its EBS volumes ordinarily remain. Check the current console association and use the approved path.
Which private storage needs the specific hibernation space and encryption prerequisites? A. The root EBS volume. B. The internet gateway. C. An SSH client key store.
Show answer
A. The supported hibernation feature saves guest memory to the encrypted EBS root volume. The volume needs space for the saved state. A network resource or local client key cannot store that guest memory for the EC2 feature.
Which statement describes a retained data volume after termination? A. The original EC2 instance can be resumed. B. The volume can remain allocated with its own costs and recovery uses. C. The volume always disappears with the root volume.
Show answer
B. Device mappings can give a data volume an independent retention setting. Its presence does not resurrect the old instance. Verify what the saved storage contains and whether it is authorized to retain or remove.
What evidence confirms a training application after restart? A. A correct authorized application response. B. Only a running label. C. An empty address list for the Region.
Show answer
A. Running status is one stage. A permitted client request returning its expected result checks application readiness. The address inventory is a separate verification of allocation and ownership.
Revision cards
- Reboot
- Restart the operating system of the same instance. Expect an interrupted session and verify service startup.
- Stop and start
- Pause a supported EBS-backed instance. Check retained storage and new ordinary public assignment before reconnecting.
- Hibernate
- Save memory under supported prerequisites. Check storage cost, resume behavior and external connections.
- Terminate
- End the instance resource permanently. Inspect per-volume retention and other allocated services.
- Protection scope
- Protection settings apply to their documented actions. Backup and recovery need their own plan.
- Cleanup and readiness
- Verify the service operation and retained resource inventory independently of the instance state.
References
- EC2 instance state changes and billing
- EC2 instance reboot behavior
- Stop and start an EC2 instance
- Instance-initiated shutdown behavior
- EC2 hibernation overview and billing
- Hibernation prerequisites
- Instance store lifetime
- EBS retention and deletion on termination
- EC2 termination protection and limitations
- EC2 stop protection
- Auto Scaling instance protection scope
- Auto Scaling Standby behavior
- EBS snapshot timing and filesystem guidance
- EC2 address assignment and lifecycle
- EC2 user-data boot behavior
- VPC pricing and allocated public IPv4
- Current AWS Free Tier terms
- AWS CLI describe-instances fields
- AWS CLI read instance protection attributes