AWS-Section6-EC2-Instance-Storage | Eloise's Paradise
0%

AWS-Section6-EC2-Instance-Storage

So in this Chapter, we will discuss the topics related to AWS ***

Analogy:Think of them as a “network USB stick”

Free tier: 30 GB of free EBS storage of type General Purpose (SSD) or Magnetic per month

multi-attach feature of EBS

You can create a EBS and then attach it to an EC2 instance. But making it available for Linux servers is out of the CCP exam scope.
EBS is indeed in bound of availability zone, meaning that an EBS created, let’s say us-east-1a, can not be attached to an EC2 instance from another availability zone: us-east-1b.

Even though EBS is available zone bounded, but snapshots of EBS can be copied to another availability zone.
EBS SNAPSHOT archive tier is 75% cheaper, but it takes 24 ~ 72 hours to restore. So it’s suitable for those data that not you are not so hurry to use.

You can delete the snapshot, and set the retention policy(1 day ~ 1 year). Within the duration of the retention, you can recover the accidentally deleted snapshot.

Copying snapshots to another availability zone is very often the usecase of disaster recovery.
With snapshots, you can also create EBS volume from it. Similarly, the newly created EBS volume doens’t have to be in the same availability zone. And from the volume list menu of the portal, you can
recognize the origin snapshot of the volume from the “snapshot” column.

Recycle Bin
Protect your Amazon EBS Snapshots and Amazon Machine Images (AMls) from accidental deletion.
Use Recycle Bin to protect your business-critical EBS Snapshots and AMIs from accidental deletion. With Recycle Bin, you specify a configurable retention period within which you can recover these resources after they have been deleted.

Lock setting of retention rule:
• Unlock
The retention rule can be modified or deleted at any time by a user with the required permissions.
• Lock
The retention rule can’t be modified or deleted until it is unlocked by a user with the required permissions, and the specified delay period has expired.

AMIs

Hands-on

  1. Launch an EC2 instance
    when launching this EC2 instance, we just put below lines into the user data: and it takes 1 ~ 2 minutes to launch because of the initialization and http installation.
    1
    2
    3
    4
    5
    6
    7
    #!/bin/bash
    # Use this for your user data (script from top to bottom)
    # install httpd (Linux 2 version)
    yum update -y
    yum install -y httpd
    systemctl start httpd
    systemctl enable httpd
  2. create an AMI from the instance
    Xnip2024-03-18_00-03-31.png
    Xnip2024-03-18_00-04-23.png
    Xnip2024-03-18_00-04-46.png
    Xnip2024-03-18_00-18-35.png
    Xnip2024-03-18_00-23-24.png
  3. Launch an EC2 instance from the AMI just created.
    This time we chose the AMI that created and owned by myself and put only this line: shell echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html into the user data
    Xnip2024-03-18_00-18-59.png
    Xnip2024-03-18_00-19-41.png
    Xnip2024-03-18_00-21-53.png
    You can feel that it’s much quicker for this 3rd instance to be available than the 2nd one, because the http is already installed back then and when we create AMI from 2nd instance, it’s also encapsulated into it.

Image builder overview

EC2 Instance Store

Xnip2024-03-18_00-45-03.png
Xnip2024-03-18_00-46-27.png

EFS

Xnip2024-03-18_00-48-27.png

EFS V.S EBS

Xnip2024-03-18_00-50-03.png

EFS IA

Xnip2024-03-18_00-51-57.png

Shared Responsibility Model for EC2 Storage

Xnip2024-03-18_00-55-12.png

Amazon FSx

Xnip2024-03-18_00-56-39.png
Xnip2024-03-18_00-58-13.png
Xnip2024-03-18_00-59-57.png

Summary

• EBS volumes:
• network drives attached to one EC2 instance at a time
• Mapped to an Availability Zones
• Can use EBS Snapshots for backups / transferring EBS volumes across AZ • AMI: create ready-to-use EC2 instances with our customizations • EC2 Image Builder: automatically build, test and distribute AMls • EC2 Instance Store:
• High performance hardware disk attached to our EC2 instance • Lost if our instance is stopped / terminated
• EFS: network file system, can be attached to 100s of instances in a region • EFS-IA: cost-optimized storage class for infrequent accessed files • FSx for Windows: Network File System for Windows servers • FSx for Lustre: High Performance Computing Linux file system

Cleanup

Before move on, we need to check the services that might cause a bill.
Xnip2024-03-18_01-03-52.png
We’ve left the Security Group and , because AWS won’t charge us for those two.

Instance termination:

Xnip2024-03-18_01-05-27.png
Xnip2024-03-18_01-05-48.png
Xnip2024-03-18_01-08-05.png

SNAPSHOT deletion

When we are trying to delete the snapshot, it failed with a prompt:
Xnip2024-03-18_01-09-04.png
Xnip2024-03-18_01-09-13.png
Xnip2024-03-18_01-09-29.png
Hence, we first, deregister the AMI that’s using the corresponding snapshot, and then remove the snapshot successfully.

AMIs deregister

You can deregister directly or first disable and then deregister. Here, we’ve shown the latter one.
Xnip2024-03-18_01-12-00.png
Xnip2024-03-18_01-12-08.png
Xnip2024-03-18_01-12-15.png
Xnip2024-03-18_01-14-06.png
Xnip2024-03-18_01-14-14.png
Xnip2024-03-18_01-14-43.png

Everything is cleaned. And we are good to go.
Xnip2024-03-18_01-19-35.png

-------------本文结束感谢您的阅读-------------