DEV Community

Seyi Lufadeju
Seyi Lufadeju

Posted on • Edited on

Hands-On Guide: AWS S3 Lifecycle Management, EBS Volume, and Snapshot

INTRODUCTION TO CORE CONCEPTS

1.1 Amazon S3 (Simple Storage Service)

- What is S3?
Amazon S3 is an object storage service that offers scalability, durability, and security. It allows you to store and retrieve any amount of data at any time.

- Storage Classes:

  • Standard: For frequently accessed data.
  • Infrequent Access (S3-IA): For less frequently accessed data (lower cost than Standard).
  • Glacier/Deep Archive: For archival data with retrieval times from minutes to hours.

- Lifecycle Management:
Automates transitioning objects between storage classes or deleting them after a defined period.


1.2 Amazon EBS (Elastic Block Store)

- What is EBS?
EBS provides block-level storage volumes for EC2 instances. Volumes persist independently of EC2 instance lifecycles.

  • Volume Types: SSD (e.g., gp3, io2) for high IOPS, HDD (e.g., st1) for throughput-intensive workloads.
  • Snapshots: Point-in-time backups of EBS volumes stored in S3.

2. Prerequisites

  • An AWS account with IAM permissions for S3, EC2, and EBS.
  • AWS CLI installed and configured (aws configure).
  • Basic familiarity with Linux commands and SSH.

3. Hands-On Implementation

Task 1: Create an S3 Bucket, Upload Files, and Configure Lifecycle Management

- Step 1: Create an S3 Bucket
Via AWS Console:

  • Go to S3 > Create bucket.

Image description

  • Enter a unique bucket name (e.g., my-project-bucket-2023).
  • Select a region (e.g., us-east-1).
  • Enable versioning (optional)
    .
    Image description

  • Click Create bucket.

Image description


- Step 2: Upload Files
Via Console:

Navigate to your bucket > Upload > Select files > Upload.

Image description

Image description

Image description

Image description


- Step 3: Configure Lifecycle Policy
Objective:

  • Transition objects to S3-IA after 30 days.
  • Transition to Glacier after 90 days.
  • Delete objects after 365 days.

Create Lifecycle Rule:

In your bucket, go to the Management tabLifecycle rulesCreate lifecycle rule.

Image description

  • Rule name: Auto-Transition-Delete.
  • Rule scope: Apply to all objects.
  • Transitions: Transition to Standard-IA: 30 days after creation. Transition to Glacier Flexible Retrieval: 90 days after creation.

Image description

Image description

  • Expiration:
    Delete objects: 365 days after creation.

  • Click Create rule.

Image description

Image description


Task 2. Create an EC2 Instance,EBS Volume, Attach to EC2, and Mount
Objective: Provision storage for an EC2 instance.

Step 1 Create an Instance

  • Select an Instance Type

Image description

  • Choose a hardware configuration:
  • For testing, select t2.micro (free tier eligible).

Image description

  • Click Next: Configure Instance Details.

Image description

Image description


Step 2: Create an EBS Volume

- Navigate to EC2 Console → Volumes → Create volume.

Image description

  • Size: Specify size (e.g., 10 GiB).
  • Availability Zone (AZ): Match the AZ of your EC2 instance (critical!).

Image description

  • Click Create volume.

Image description

Image description


- Step 3: Attach the EBS Volume to an EC2 Instance

- Attach Volume:

  • Right-click the new volume → Attach volume.

Image description

  • Instance: Select your EC2 instance.
  • Device name: Use /dev/sdf (Linux) or /dev/xvdf.
  • Click Attach.

Image description

Image description


Step 3: Mount the EBS Volume on Linux

- SSH into the EC2 Instance:

ssh -i "my-key.pem" ubuntu@ec2-13-51-36-103.eu-north-1.compute.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

Image description

- Format and Mount:

  • List disks: lsblk (identify the new volume, e.g., nvme1n1).

Image description

  • Format the volume:
sudo mkfs -t ext4 /dev/nvme1n1
Enter fullscreen mode Exit fullscreen mode

Image description

- Create a mount directory:

sudo mkdir /mnt/ebs-volume
Enter fullscreen mode Exit fullscreen mode

- Mount the volume:

sudo mount /dev/nvme1n1 /mnt/ebs-volume
Enter fullscreen mode Exit fullscreen mode

- Auto-mount on reboot:

echo "/dev/nvme1n1 /mnt/ebs-volume ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
Enter fullscreen mode Exit fullscreen mode

Image description

Image description


- Confirm if your Ebs-volume remain persistent after Reboot
Reboot Instance

Image description

Re-Connect to Instance

Image description

Confirm the Ebs-Volume remained mounted
Image description


Task 3. Create an EBS Snapshot

  • Objective: Backup your EBS volume.

- Step 1: Create a Snapshot
Navigate to EC2 Console → Volumes → Select your EBS volume.

  • Create Snapshot:
  • Click Actions → Create snapshot.

Image description

  • Description: Add a name (e.g., my-ebs-backup-2023).
  • Click Create snapshot.

Image description

Image description

- Step 2: Verify Snapshot (Optional)
Go to Snapshots in the EC2 console. Your snapshot will appear once complete.

Image description


Conclusion

This project provided a hands-on exploration of two foundational AWS services: Amazon S3 for scalable object storage and Amazon EBS for persistent block storage. By completing the tasks, we’ve gained practical experience in automating data lifecycle management, provisioning storage resources, and ensuring data durability through backups. Below is a detailed breakdown of the key takeaways:


Key Achievements

- Automated Data Lifecycle Management with S3:

You configured lifecycle policies to transition objects between storage classes (Standard → S3-IA → Glacier) and delete them after a defined period. This demonstrates how businesses can optimize costs by aligning storage costs with data access patterns.

Real-World Use Case: Archiving logs, media, or compliance data that loses relevance over time but requires long-term retention.

- EBS Volume Setup and Integration with EC2:

By creating, attaching, and mounting an EBS volume, you learned how block storage complements EC2 instances. This is critical for applications requiring persistent data (e.g., databases, file servers).

Challenge Addressed: Ensuring data persists even if the EC2 instance is stopped or terminated.

- Data Protection with EBS Snapshots:

Snapshots provide point-in-time backups stored in S3, enabling disaster recovery. This is essential for compliance (e.g., GDPR, HIPAA) and minimizing downtime.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️