Chapter 14: EC2 Operations — Elastic IP, AMI, Snapshots and Vertical Scaling
Hello friends! Launching a server is only the first day. In real projects the day-two work matters more: keeping the same IP when you change the server, a backup before an upgrade, cloning a configured server in minutes, and more CPU/RAM for a slow server. Example: the web server of Mauli Dairy, Pune (a fictional business, only for learning). Do every lab with me and at the end release the resources you don't need.
नमस्कार मित्रांनो! सर्व्हर लॉन्च करणं म्हणजे फक्त पहिला दिवस. खऱ्या प्रोजेक्ट्समध्ये दुसऱ्या दिवसाचं काम जास्त महत्त्वाचं असतं: सर्व्हर बदलला तरी तोच IP ठेवणं, अपग्रेडआधी बॅकअप, कॉन्फिगर केलेल्या सर्व्हरचा मिनिटांत क्लोन, आणि स्लो सर्व्हरला जास्त CPU/RAM. उदाहरण: Mauli Dairy, Pune (काल्पनिक बिझनेस, फक्त शिकण्यासाठी) चा वेब सर्व्हर. प्रत्येक लॅब माझ्यासोबत करा आणि शेवटी नको असलेले रिसोर्सेस रिलीज करा.
नमस्ते दोस्तों! सर्वर लॉन्च करना बस पहला दिन है. असली प्रोजेक्ट्स में दूसरे दिन का काम ज़्यादा ज़रूरी होता है: सर्वर बदलने पर भी वही IP रखना, अपग्रेड से पहले बैकअप, कॉन्फ़िगर किए सर्वर का मिनटों में क्लोन, और स्लो सर्वर को ज़्यादा CPU/RAM. उदाहरण: Mauli Dairy, Pune (काल्पनिक बिज़नेस, सिर्फ़ सीखने के लिए) का वेब सर्वर. हर लैब मेरे साथ करो और आख़िर में जो रिसोर्सेस नहीं चाहिए उन्हें रिलीज़ करो.
What you will learn in this chapter
- Elastic IP in depth
- Server swap with no DNS change
- Creating and launching AMIs
- Copying and sharing AMIs
- Restoring one file from a snapshot
- Automating snapshots with DLM
- Changing the instance type
- Scale up vs scale out
Friends, launching a server is only day one. In real projects, the day-two work matters more: keeping the same IP when you replace a server, taking a backup before an upgrade, cloning a perfectly configured server in minutes, and giving a slow server more CPU and RAM. This is a very practical chapter – let's learn these operations one by one, and please do every lab with me. We will try all of this on Mauli Dairy's server.
मित्रांनो, सर्व्हर लॉन्च करणं हा फक्त पहिला दिवस. खऱ्या प्रोजेक्ट्समध्ये दुसऱ्या दिवसाचं काम जास्त महत्त्वाचं: सर्व्हर बदलताना तोच IP ठेवणं, अपग्रेडआधी बॅकअप घेणं, उत्तम कॉन्फिगर केलेल्या सर्व्हरचा मिनिटांत क्लोन करणं, आणि स्लो सर्व्हरला जास्त CPU आणि RAM देणं. एकदम प्रॅक्टिकल चॅप्टर आहे – ही ऑपरेशन्स एकेक करून शिकूया, आणि प्रत्येक लॅब माझ्यासोबत करा. Mauli Dairy च्या सर्व्हरवर हे सगळं आपण करून बघू.
दोस्तों, सर्वर लॉन्च करना बस पहला दिन है. असली प्रोजेक्ट्स में दूसरे दिन का काम ज़्यादा ज़रूरी है: सर्वर बदलते समय वही IP रखना, अपग्रेड से पहले बैकअप लेना, अच्छे से कॉन्फ़िगर किए सर्वर का मिनटों में क्लोन बनाना, और स्लो सर्वर को ज़्यादा CPU और RAM देना. एकदम प्रैक्टिकल चैप्टर है – ये ऑपरेशन्स एक-एक करके सीखते हैं, और हर लैब मेरे साथ करो. Mauli Dairy के सर्वर पर ये सब हम करके देखेंगे.
Day-two operations on one EC2 web server
+------------------+ +-------------------+ +---------------------+
| Elastic IP | | AMI (golden | | Change instance |
| fixed address | | image / clone) | | type (scale up) |
+--------+---------+ +---------+---------+ +----------+----------+
| | |
v v v
+--------------------------------------------------------------------+
| EC2 instance ── EBS root volume ──► EBS snapshots (backups) |
+--------------------------------------------------------------------+
Concepts in this chapter
- 14.1Elastic IP in depth
- 14.2AMI (Amazon Machine Image)
- 14.3EBS snapshots in practice
- 14.4Vertical scaling: changing the instance type
Review and practice
Practice Tasks
Hyderabad Biryani Hub is a cloud kitchen business in Hyderabad. Syed Imran looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-2 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 12
Easy Snapshot an EBS volume
Why: A snapshot is a point-in-time backup of one disk, kept in S3 by AWS.
What to do: Create a snapshot of volume vol-00300c2e3d3cfdeed with description "nightly hydbiryani".
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Detach a volume
Why: To move a disk to a rescue server, detach it first.
What to do: Detach volume vol-00300c2e3d3cfdeed.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Delete an old AMI
Why: Old AMIs and their snapshots cost money every month.
What to do: Deregister the image ami-01b0b002afb1babcd.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium List your own AMIs
Why: Only images you own matter when you clean up old AMIs.
What to do: List only the AMIs owned by your own account.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Allocate an Elastic IP
Why: An Elastic IP stays the same after stop/start, so DNS keeps working.
What to do: Allocate a new Elastic IP address for use in a VPC.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Attach the Elastic IP to the server
Why: Associating gives the server the fixed public IP that your domain points to.
What to do: Associate allocation eipalloc-00300d2b3c3dd44 with instance i-03c3b2d0030311a2b.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Create an AMI from a server
Why: An AMI is a full server image. Launch identical copies from it any time.
What to do: Create an AMI named hydbiryani-web-v1 from instance i-03c3b2d0030311a2b.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Attach a volume to an instance
Why: A volume must be attached (same AZ) before the server can see it.
What to do: Attach volume vol-00300c2e3d3cfdeed to instance i-03c3b2d0030311a2b as device /dev/sdf.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Make a compressed backup
Why: A .tar.gz file packs a whole folder into one small file you can copy anywhere.
What to do: Create a gzip-compressed archive named hydbiryani-site.tar.gz from the folder /var/www/hydbiryani.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Medium Extract a backup
Why: To restore, you unpack the archive into a folder.
What to do: Extract hydbiryani-site.tar.gz into the folder /tmp/restore.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Medium Zip a folder
Why: Zip files open easily on Windows, so they are good for sharing with office staff.
What to do: Create invoices.zip containing the folder invoices and everything in it.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Hard Copy a snapshot to another Region
Why: A copy in another Region protects you if a whole Region has a problem.
What to do: Copy snapshot snap-000f2e3e3beef5 from ap-south-2 into us-west-2 (run the command in us-west-2).
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.