Chapter 5: Amazon EC2 (Elastic Compute Cloud)
5.7 EC2 best practices
Friends, these rules are not just for interviews – you need them every day on a real server. Once the Amul-style dairy's server is live, check every point below once.
मित्रांनो, हे नियम फक्त इंटरव्ह्यूसाठी नाहीत – रिअल सर्व्हरवर रोज लागतात. The Amul-style dairy चा सर्व्हर लाइव्ह झाला की खालचा प्रत्येक पॉइंट एकदा चेक करा.
दोस्तों, ये नियम सिर्फ़ इंटरव्यू के लिए नहीं हैं – रियल सर्वर पर रोज़ काम आते हैं. The Amul-style dairy का सर्वर लाइव होते ही नीचे का हर पॉइंट एक बार चेक करो.
- Least privilege security groups: SSH (22) only from My IP; never open databases (3306, 27017) to
0.0.0.0/0. - Protect keys:
chmod 400, one key per person/team, rotate when someone leaves. Never commit keys to Git. - Use IAM roles for instances instead of storing AWS access keys on the server.
- Keep the OS patched:
sudo yum update -y/sudo apt upgrade -yregularly. - Right-size: start small (
t3.micro), monitor with CloudWatch, then scale up. - Tag everything:
Name,Owner,Project,Environment— helps billing and clean-up. - Backups: EBS snapshots (automate with Amazon Data Lifecycle Manager) or AMIs.
- Use Elastic IP or a DNS name for servers that need a fixed address.
- High availability: production apps run in ≥ 2 AZs behind a load balancer.
- Cost hygiene: stop idle instances; delete unattached volumes, old snapshots and unused EIPs; set AWS Budgets alerts.
- Monitor: CloudWatch metrics and alarms (CPU, status check failures).
Ravindra Bagale's Tip
Many students give an instance only a Name tag and forget the Owner and Project tags – then at the end of the month nobody knows which server belongs to whom, and the clean-up never happens. Add tags like Project=mauli-dairy and Environment=dev while launching. Don't forget this at all.
Ravindra Bagale's Tip – मराठी
बरेच students instance ला फक्त Name tag देतात आणि Owner, Project tags विसरतात – मग महिन्याच्या शेवटी कोणता server कोणाचा हे कळत नाही आणि clean-up राहून जातं. Launch करतानाच Project=mauli-dairy, Environment=dev सारखे tags लावा. बिलकुल विसरू नका.
Ravindra Bagale's Tip – हिंदी
बहुत से students instance को सिर्फ़ Name tag देते हैं और Owner, Project tags भूल जाते हैं – फिर महीने के आखिर में पता नहीं चलता कि कौन सा server किसका है, और clean-up रह जाता है. Launch करते समय ही Project=mauli-dairy, Environment=dev जैसे tags लगाओ. बिल्कुल मत भूलना.
Lab
Tumchya mauli-web-1 cha chhota audit kara: security group madhe 22 fakt My IP la aahe ka, Name, Owner, Project aani Environment tags aahet ka, sudo yum update -y kela ka, aani termination protection on aahe ka. Ek AWS Budget e-mail alert suddha set kara.
Extended teaching notes
Why this lesson matters
Cloud security is mostly IAM, network exposure, logging and secure defaults. The shared responsibility model means the provider patches the metal; you patch what you configure.
- No public databases or public admin panels.
- Roles / OIDC instead of long-lived access keys.
- CloudTrail / Activity Logs / Audit Logs on and retained.
- S3/Blob/GCS: Block Public Access; encrypt; least privilege.
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.