AWS S3 — Introduction of S3 and practical example to access the data from S3 in EC2 Instances

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. Here’s a detailed explanation:

What is Amazon S3?

Amazon S3 is designed to store and retrieve any amount of data from anywhere on the web. It is highly durable and available, making it suitable for a wide range of use cases, such as data lakes, websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics.

Key Features of Amazon S3:

  1. Scalability: S3 can handle virtually unlimited amounts of data.

  2. Durability: S3 is designed for 99.999999999% (11 9’s) durability.

  3. Availability: S3 provides 99.99% availability over a given year.

  4. Security: S3 supports data encryption and access management tools.

  5. Storage Classes: S3 offers different storage classes for various use cases, such as S3 Standard, S3 Intelligent-Tiering, S3 Glacier, and more.

Task:

  • Launch an EC2 instance using the AWS Management Console and connect to it using Secure Shell (SSH).

  • Create an S3 bucket and upload a file to it using the AWS Management Console.

  • Access the file from the EC2 instance using the AWS Command Line Interface (AWS CLI).

Solution:

By now, you should be able to connect to an EC2 instance, so I am skipping this part.

Create S3 bucket:

For this example, I’ll be uploading an image file.

Access the file:

Before starting, make sure your user has S3 access to interact with S3 files.

To interact, I’ll be using AWS commands. You can find a few of them here.

  • List the contents of the bucket.
aws s3 ls

  • Download the file to your local machine.
aws s3 cp s3://BUCKET_NAME/FILE

  • As you remember, we keep the checkbox checked to block public access. To grant Temporary Access, we can use Pre-signed URLs:

It is a handy feature in AWS S3 for securely sharing access to objects without making them publicly accessible. Here are a few key points to remember:

  1. Temporary Access: Pre-signed URLs grant temporary access to an S3 object. The duration can be customized based on your needs.

  2. Use Cases: They are useful for sharing files with external users, allowing temporary access to private objects, or enabling secure uploads.

  3. Security: Since the URL includes a signature, it’s important to keep it confidential. Anyone with the URL can access the object until it expires.

aws s3 presign s3://BUCKET_NAME/FILE --expires-in 60

I set it to expires in 60 seconds.

Thank you for reading😉.

0
Subscribe to my newsletter

Read articles from Sundaresan Anandan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sundaresan Anandan
Sundaresan Anandan

I am a tech enthusiast and have dedicated 5+ years of experience in software development. Currently, I am working as a solution engineer. Here my responsibilities are to directly interact with customers and fellow developers, then identify their pain points and figure out the solutions. Apart from that, I spent plenty of time code along with other developers, writing technical documents and preparing architecture diagrams.