Bird
Raised Fist0
AWScloud~15 mins

Instance states (running, stopped, terminated) in AWS - Deep Dive

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Overview - Instance states (running, stopped, terminated)
What is it?
Instance states describe the current condition of a virtual server (called an instance) in the cloud. Common states include running, stopped, and terminated. Each state tells you if the instance is active, paused, or permanently deleted. Understanding these states helps you manage your cloud servers effectively.
Why it matters
Without knowing instance states, you might waste money paying for servers you don't use or lose data by accidentally deleting an instance. Properly managing states ensures you only pay for what you need and keep your applications available. It also helps avoid confusion about whether your server is ready or offline.
Where it fits
Before learning instance states, you should understand what a cloud instance is and basic cloud concepts like virtual servers and billing. After this, you can learn about instance lifecycle management, automation, and cost optimization strategies.
Mental Model
Core Idea
An instance state is like a traffic light showing whether a cloud server is active, paused, or gone, guiding how you can interact with it.
Think of it like...
Think of a cloud instance like a car: 'running' means the car is on and driving, 'stopped' means the car is parked but can start again, and 'terminated' means the car is scrapped and gone forever.
┌─────────────┐      start      ┌─────────────┐
│   Stopped   │ ─────────────> │   Running   │
└─────────────┘                └─────────────┘
       ▲                            │
       │          stop              │ terminate
       │ <─────────────────────────┘
┌─────────────┐
│ Terminated  │
└─────────────┘
Build-Up - 7 Steps
1
FoundationWhat is an Instance State
🤔
Concept: Instance states represent the current status of a cloud server.
A cloud instance is a virtual computer you can use remotely. It can be in different states: running (active and working), stopped (powered off but still exists), or terminated (deleted and gone). These states tell you what you can do with the instance.
Result
You understand that instance states are labels showing if your cloud server is on, off, or deleted.
Knowing instance states is the first step to controlling your cloud servers and managing costs.
2
FoundationRunning State Explained
🤔
Concept: Running means the instance is active and ready to use.
When an instance is running, it behaves like a normal computer: you can connect to it, run programs, and it uses cloud resources. You are billed for the time it runs. This is the state where your applications are live.
Result
You can access and use the instance like a real computer.
Understanding running state helps you know when your server is actually working and costing money.
3
IntermediateStopped State Details
🤔Before reading on: do you think a stopped instance still costs the same as a running one? Commit to your answer.
Concept: Stopped means the instance is powered off but still exists in your account.
When you stop an instance, it shuts down like turning off a computer. You can't use it until you start it again. You don't pay for compute time, but storage costs remain because the instance's data is saved. This state is useful to pause usage without losing data.
Result
The instance is off, not using compute resources, but data is preserved and you can restart it later.
Knowing stopped state helps you save money while keeping your data and setup intact.
4
IntermediateTerminated State and Its Impact
🤔Quick: Does terminating an instance allow you to restart it later? Commit to yes or no.
Concept: Terminated means the instance is permanently deleted and cannot be recovered.
When you terminate an instance, it is removed from your cloud account. All data on the instance is lost unless you saved it elsewhere. You stop paying for it completely. This is like scrapping a car; you can't use it again.
Result
The instance is gone forever, freeing up resources and stopping all charges.
Understanding termination prevents accidental data loss and helps manage resource cleanup.
5
IntermediateState Transitions and Lifecycle
🤔Before reading on: Can you move directly from stopped to terminated without running the instance? Commit to your answer.
Concept: Instances move between states through actions like start, stop, and terminate.
You can start a stopped instance to make it running again. You can stop a running instance to pause it. You can terminate an instance from running or stopped states. These transitions define the lifecycle of an instance and control billing and availability.
Result
You understand how to change instance states and what each transition means.
Knowing lifecycle transitions helps you plan instance usage and avoid unexpected charges or data loss.
6
AdvancedBilling Implications of States
🤔Do you think stopped instances incur compute charges? Commit to yes or no.
Concept: Billing depends on instance state: running instances incur compute charges, stopped do not, terminated stop all charges.
When running, you pay for compute and storage. When stopped, compute charges stop but storage charges continue because your data is saved. When terminated, all charges stop. This billing model encourages efficient use of resources.
Result
You can optimize costs by stopping instances when not in use and terminating when no longer needed.
Understanding billing tied to states helps control cloud costs effectively.
7
ExpertUnexpected Behaviors and Edge Cases
🤔Can stopping an instance change its IP address? Commit to yes or no.
Concept: Some instance properties change when stopped, like dynamic IP addresses, which can affect connectivity.
When you stop and start an instance, it may get a new public IP address unless you use static IPs (Elastic IPs). Also, some instance types or attached resources behave differently on stop/start. Knowing these details prevents surprises in production environments.
Result
You anticipate and manage changes in instance behavior during state transitions.
Knowing these edge cases avoids downtime and connectivity issues in real-world cloud operations.
Under the Hood
Cloud providers track instance states in their control plane, managing resources like CPU, memory, and storage accordingly. Running instances have active compute resources assigned. Stopped instances release compute but keep storage volumes attached. Terminated instances remove all resources and metadata. State changes trigger automated workflows to allocate or free resources.
Why designed this way?
This design balances user flexibility and cost efficiency. Allowing stopped states lets users pause compute costs without losing data. Termination frees all resources to avoid waste. Alternatives like always running or instant deletion would either waste money or risk data loss.
┌─────────────┐       ┌─────────────┐       ┌─────────────┐
│  User/API   │──────▶│ Control     │──────▶│ Infrastructure│
│  Requests   │       │ Plane       │       │ Resources    │
└─────────────┘       └─────────────┘       └─────────────┘
       │                    │                     │
       │  Change State       │  Allocate/Release   │
       │────────────────────▶│────────────────────▶│
       │                    │                     │
Myth Busters - 4 Common Misconceptions
Quick: Does stopping an instance delete its data? Commit to yes or no.
Common Belief:Stopping an instance deletes all its data and configuration.
Tap to reveal reality
Reality:Stopping only powers off the instance; data on attached storage remains intact.
Why it matters:Believing this causes unnecessary data backups or fear of stopping instances, leading to inefficient cloud use.
Quick: Can you restart a terminated instance? Commit to yes or no.
Common Belief:Terminated instances can be restarted later if needed.
Tap to reveal reality
Reality:Terminated instances are permanently deleted and cannot be restarted.
Why it matters:Misunderstanding this can cause accidental data loss and downtime.
Quick: Do stopped instances incur the same charges as running ones? Commit to yes or no.
Common Belief:Stopped instances cost the same as running instances because they still exist.
Tap to reveal reality
Reality:Stopped instances do not incur compute charges, only storage charges.
Why it matters:This misconception leads to unnecessary costs by keeping instances running when they could be stopped.
Quick: Does stopping and starting an instance always keep the same IP address? Commit to yes or no.
Common Belief:An instance keeps the same public IP address after stopping and starting.
Tap to reveal reality
Reality:Public IP addresses often change after stop/start unless a static IP is assigned.
Why it matters:Assuming IP stability causes connection failures and service disruptions.
Expert Zone
1
Stopping an instance releases compute resources but preserves the root volume, which may cause delays when restarting due to reallocation.
2
Terminating an instance deletes ephemeral storage but not attached persistent volumes unless explicitly configured.
3
Some instance types do not support stopping and must be terminated to release resources.
When NOT to use
Avoid relying on stopped state for long-term data storage; use dedicated storage services instead. For critical services requiring fixed IPs, use Elastic IPs or load balancers rather than expecting IP persistence. When instances must always be available, consider auto-scaling groups instead of manual start/stop.
Production Patterns
In production, teams automate instance state changes using scripts or cloud tools to save costs during off-hours. They use termination policies to clean up unused instances and prevent resource leaks. Elastic IPs and persistent storage are used to maintain connectivity and data across stop/start cycles.
Connections
State Machines
Instance states follow a state machine pattern with defined transitions.
Understanding instance states as a state machine helps design reliable automation and error handling.
Operating System Power States
Cloud instance states mirror OS power states like running, sleep, and shutdown.
Knowing OS power states clarifies why instances behave differently in running vs stopped states.
Project Management Task Status
Instance states are like task statuses: active, paused, or completed.
Seeing instance states as task statuses helps non-technical people grasp lifecycle and transitions.
Common Pitfalls
#1Assuming stopping an instance stops all charges.
Wrong approach:Stop instance and forget about storage costs, expecting zero charges.
Correct approach:Stop instance and monitor storage costs; consider deleting unused volumes to save money.
Root cause:Misunderstanding that storage costs continue even when compute is stopped.
#2Terminating an instance without backing up data.
Wrong approach:Terminate instance directly after use without snapshots or backups.
Correct approach:Create snapshots or backups before terminating to preserve data.
Root cause:Not realizing termination deletes instance and attached ephemeral storage permanently.
#3Expecting the same public IP after stop/start without configuration.
Wrong approach:Stop and start instance assuming IP address remains unchanged.
Correct approach:Assign Elastic IP to instance to keep a fixed public IP across stop/start.
Root cause:Not knowing that public IPs are dynamically assigned unless made static.
Key Takeaways
Instance states tell you if a cloud server is active, paused, or deleted, guiding your interaction and billing.
Running instances use compute resources and cost money; stopped instances save compute costs but keep data and storage charges.
Terminated instances are permanently deleted and cannot be recovered, so backup before termination is critical.
State transitions control the lifecycle of instances and affect availability, cost, and connectivity.
Understanding these states and their implications helps you manage cloud resources efficiently and avoid costly mistakes.

Practice

(1/5)
1. Which AWS EC2 instance state means the instance is currently powered on and ready to use?
easy
A. Running
B. Stopped
C. Terminated
D. Pending

Solution

  1. Step 1: Understand EC2 instance states

    Instances can be in states like running, stopped, or terminated, indicating their power and availability status.
  2. Step 2: Identify the state meaning 'powered on'

    The 'running' state means the instance is powered on and ready to use.
  3. Final Answer:

    Running -> Option A
  4. Quick Check:

    Running = Powered On [OK]
Hint: Running means instance is on and usable [OK]
Common Mistakes:
  • Confusing stopped with running
  • Thinking terminated means running
  • Mixing pending with running
2. Which AWS CLI command correctly stops a running EC2 instance with ID i-1234567890abcdef0?
easy
A. aws ec2 terminate-instances --instance-ids i-1234567890abcdef0
B. aws ec2 reboot-instances --instance-ids i-1234567890abcdef0
C. aws ec2 start-instances --instance-ids i-1234567890abcdef0
D. aws ec2 stop-instances --instance-ids i-1234567890abcdef0

Solution

  1. Step 1: Identify command to stop instance

    The command to stop an instance is stop-instances.
  2. Step 2: Match instance ID usage

    The command must include --instance-ids i-1234567890abcdef0 to specify the instance.
  3. Final Answer:

    aws ec2 stop-instances --instance-ids i-1234567890abcdef0 -> Option D
  4. Quick Check:

    Stop instance = stop-instances command [OK]
Hint: Stop instance uses 'stop-instances' command [OK]
Common Mistakes:
  • Using terminate instead of stop
  • Using start instead of stop
  • Using reboot instead of stop
3. What will be the state of an EC2 instance immediately after running this AWS CLI command?
aws ec2 terminate-instances --instance-ids i-0abcdef1234567890
medium
A. Running
B. Stopped
C. Terminated
D. Pending

Solution

  1. Step 1: Understand the terminate-instances command

    This command deletes the instance permanently, changing its state to terminated.
  2. Step 2: Identify the resulting state

    After termination, the instance cannot be started again and is marked as terminated.
  3. Final Answer:

    Terminated -> Option C
  4. Quick Check:

    Terminate command = Terminated state [OK]
Hint: Terminate means instance is deleted permanently [OK]
Common Mistakes:
  • Thinking terminated means stopped
  • Confusing terminate with stop
  • Expecting instance to restart automatically
4. You tried to start an EC2 instance but got an error saying the instance does not exist. What is the most likely cause?
medium
A. The instance is terminated
B. The instance is in running state
C. The instance is in stopped state
D. The instance is pending

Solution

  1. Step 1: Analyze error meaning

    If AWS says the instance does not exist, it usually means it was deleted or terminated.
  2. Step 2: Match instance state to error

    Terminated instances are removed and cannot be started again, causing this error.
  3. Final Answer:

    The instance is terminated -> Option A
  4. Quick Check:

    Instance not found = Terminated state [OK]
Hint: Instance not found means terminated, not stopped [OK]
Common Mistakes:
  • Assuming stopped means instance missing
  • Confusing running with missing
  • Ignoring termination possibility
5. You want to save costs by stopping an EC2 instance but keep its data intact for later use. Which instance state should you use and why?
hard
A. Terminate, because it deletes the instance and saves all costs
B. Stop, because it powers off the instance but keeps data on the disk
C. Running, because it keeps the instance active and data safe
D. Pending, because it prepares the instance for shutdown

Solution

  1. Step 1: Understand cost and data retention

    Stopping an instance powers it off but keeps the attached storage intact, preserving data.
  2. Step 2: Compare with termination

    Terminating deletes the instance and storage, losing data and cannot be restarted.
  3. Step 3: Choose correct state for saving costs and keeping data

    Stopping is the correct choice to save costs while keeping data safe.
  4. Final Answer:

    Stop, because it powers off the instance but keeps data on the disk -> Option B
  5. Quick Check:

    Stop = Save cost + keep data [OK]
Hint: Stop to save cost and keep data intact [OK]
Common Mistakes:
  • Choosing terminate and losing data
  • Thinking running saves cost
  • Confusing pending with stop