DEV Community

Cover image for πŸ›‘οΈ AWS 108: Adding a Safety Latch - Enabling EC2 Stop Protection
Hritik Raj
Hritik Raj

Posted on

πŸ›‘οΈ AWS 108: Adding a Safety Latch - Enabling EC2 Stop Protection

AWS

πŸ”’ Shield Your Servers: Preventing Accidental Shutdowns

Hey Cloud Guardians! πŸ‘‹

Welcome to Day 8 of the #100DaysOfCloud Challenge: Enable Stop Protection! As the Nautilus DevOps team moves more mission-critical data into AWS, they’ve realized that some servers are too important to go offline. Following the roadmap from KodeKloud Engineer, today we are adding an extra layer of "human-error" insurance to our infrastructure.

Our mission: Enable Stop Protection for the instance named datacenter-ec2 in the us-east-1 region.


1. Introduction: What is Stop Protection? πŸ’‘

In a busy DevOps environment, accidents happen. A simple mistake in the console or a rogue script could accidentally stop a production server, leading to unnecessary downtime.

  • Stop Protection: When enabled, this prevents the instance from being stopped via the AWS Management Console, CLI, or API.
  • The Error Message: If someone tries to stop it, AWS will return an error until the protection is manually disabled.
  • Why it Matters: For core application hubs like datacenter-ec2, an unexpected shutdown could disrupt the entire migration. This ensures that stopping the server is a deliberate, two-step process.

Let's lock it down! πŸ›‘οΈ


2. Step-by-Step Guide: Locking the datacenter-ec2 Instance

We will use the AWS Management Console to modify the instance attributes.

Step 2.1: Locate your Instance

  1. Log in to the AWS Console and navigate to the EC2 Dashboard.
  2. Ensure your region is set to US East (N. Virginia) us-east-1.

  1. Click on "Instances (running)".

  1. Find and select the instance named datacenter-ec2.

Step 2.2: Modify Stop Protection

  1. With the instance selected, click the "Actions" button at the top.
  2. Navigate to "Instance settings" -> "Change stop protection".

  1. In the configuration screen, check the box that says "Enable".
  2. Click "Save".

Step 2.3: Verify the Protection

  1. While the instance is still selected, try to click "Instance state" -> "Stop instance".
  2. You should see a notification or an error message stating that the instance has stop protection enabled and cannot be stopped.

Success! Your server is now safe from accidental shutdowns. πŸŽ‰


3. Key Takeaways πŸ“

  • Human Error Mitigation: Protection features are designed to stop "accidental" clicks, not to prevent authorized admins from ever stopping the server.
  • Two-Step Process: To stop this server in the future, an admin must first disable the protection and then issue the stop command.
  • Operational Stability: This setting is a best practice for "Always-On" resources like databases or NAT instances.

4. Common Mistakes to Avoid 🚫

  1. Thinking it's Permanent: Protection doesn't mean the server can never be stopped; it just adds a "Are you sure?" step.
  2. OS-Level Shutdowns: Important! Stop protection usually only prevents stops initiated via AWS tools (Console/CLI). If you log into the server via SSH and run sudo shutdown now, the server will still stop!
  3. Forgetting it's On: During scheduled maintenance windows, remember to disable the protection first, or your automation scripts might fail.

5. Conclusion + Call to Action! 🌟

Security isn't just about firewalls; it's also about operational stability. By enabling stop protection, you've ensured the Nautilus team's migration stays on track without accidental interruptions.

Are you following along with the 100 Days of Cloud Challenge?

  • πŸ’¬ Let’s connect on LinkedIn: Let's talk about cloud governance and best practices! πŸ‘‰ Hritik Raj
  • ⭐ Support my journey on GitHub: View the documentation for this task and more. πŸ‘‰ GitHub – 100 Days of Cloud

Top comments (0)