AWS S3 πŸ—‚οΈSimplified: Cloud☁️ Storage Made EasyπŸ› οΈ

AWS S3 πŸ—‚οΈSimplified: Cloud☁️ Storage Made EasyπŸ› οΈ

Day 3 : ⚑ Explore features, use cases, and practical demo on cloud storage πŸ“€ S3

Β·

8 min read

In this article, I will be discussing one of the most popular and commonly used AWS servicesβ€”or perhaps the very first service that many of us encounter when starting our AWS journey (though not in my case).

This article covers the fundamentals of S3 Buckets πŸ—ƒοΈ, key terms related to the service πŸ“š, and well-documented steps with clear explanations πŸ”. You'll learn about the essential terms you'll encounter while creating an S3 bucket and hosting a static website 🌐. Plus, a practical video πŸŽ₯ will walk you through this simple project, making it easy to follow along!


What is an S3 Bucket?

It solves the problem of storage

An S3 bucket is a virtual container in AWS S3 (Amazon Simple Storage Service) where you can store your data, such as files, images, videos, or any other objects. Think of it as a folder in the cloud, but with powerful capabilities for storage, organization, and accessibility.

How Amazon S3 works ?

Amazon S3 is an object storage service that stores data as objects within buckets. An object is a file and any metadata that describes the file. A bucket is a container for objects.

To store your data in Amazon S3, you first create a bucket and specify a bucket name and AWS Region. Then, you upload your data to that bucket as objects in Amazon S3. Each object has a key (or key name), which is the unique identifier for the object within the bucket.

We can use S3 Bucket to store any static content but as a DevOps Engineer, S3 Buckets are used to store backups and logs etc

Storage for an bucket is unlimited but an object size cannot be more than 5TB (if this size limit exceeds then the object can be stored using multipart uploads)

πŸ’‘
S3 is a GLOBAL ACCESSIBLE SERVICE

These are according to AWS Official Documentation

1. Buckets πŸ—ƒοΈ

  • Buckets are like storage containers in Amazon S3, where you store all your data (files).

  • You can have up to 10,000 buckets by default, and each one must have a unique name.

  • Each bucket resides in a specific AWS region 🌍.

2. Objects πŸ“‚

  • Objects are the files (images, documents, videos, etc.) stored inside a bucket.

  • They consist of data and metadata (information about the file).

  • Every object has a unique key (file name) to identify it.

3. Keys πŸ”‘

  • An object key is the unique identifier for a file within a bucket.

  • The key is part of the URL used to access the object, e.g., photos/puppy.jpg.

4. S3 Versioning πŸ”„

  • With S3 Versioning, you can keep multiple versions of the same object in one bucket.

  • This helps restore previous versions in case of accidental changes or deletions.

5. Version ID πŸ†”

  • When you enable S3 Versioning, Amazon S3 assigns a unique version ID to every object.

  • Older objects that existed before versioning have a null version ID.

6. Bucket Policy πŸ“œ

  • A bucket policy is a set of rules that control who can access the bucket and its objects.

  • You can define permissions for different users or actions, like allowing access from a specific IP address or granting cross-account permissions.

7. S3 Access Points 🌐

  • S3 Access Points are like custom access endpoints to manage how data is accessed in a bucket.

  • Each access point has its own policy to control access.

8. Access Control Lists (ACLs) πŸ”

  • ACLs are used to grant specific permissions for individual objects or buckets.

  • They let you control who can read or write to a file but are less commonly used today in favor of policies.

9. Regions 🌍

  • You can choose the AWS region where your S3 bucket will be located.

  • Choosing a region can help reduce latency, lower costs, or meet regulatory requirements.

  • Objects stored in a region stay within that region unless transferred.

    πŸ’‘
    Object Lock, S3 Replication, S3 Object Ownership, Block Public Access, Bucket Versioning, Server Access Logging, Storage Classes : All these terms have been properly explained in the video that’s why I am not including its explanation here

Practical Implementation

Lets start with process of hosting a simple static website on the bucket

Click here to watch tutorial

πŸŽ₯ After watching the video, follow these steps to implement the process at your own pace. In my video, I'll also share some extra insights πŸ’‘ that might not be included in these steps. These additional points will give you a deeper understanding and enhance your learning! πŸš€

πŸ“Œ That's exactly why I started providing videos β€” so I can share those extra nuggets of information 🎀 to make the process even clearer and more engaging for you all! 😊

Step 1: Sign in to AWS Console

  • What to do: Go to the AWS Management Console and log in with your credentials.

  • Reason: You need access to AWS services, including S3, to create and manage your bucket.

Step 2: Create a New S3 Bucket πŸ—ƒοΈ

  • What to do:

    • Navigate to S3 under Services.

    • Click on Create bucket.

    • Choose a unique bucket name (e.g., my-static-website-bucket).

    • Select an AWS Region (e.g., US-East-1) that is closest to your users for low latency ⚑.

    • Leave other options as default for now and click Create.

  • Reason:

    • The bucket name is unique globally, ensuring that no other AWS user has the same name.

    • The Region helps you decide where your data will be stored physically 🌍.

    • NOTE : Although S3 is a Global Service but it requires a region to store your data

Step 3: Upload Your Website Files πŸ“

  • What to do:

    • Inside your newly created bucket, click Upload.

    • Select your website files (index.html, style.css, etc.).

    • Click Upload to store these files in the bucket.

  • Reason:

    • You need to upload your website files (like HTML, CSS, and images) to the bucket in order for them to be served to users.

    • index.html is the main file that browsers look for when accessing the website.

Step 4: Enable Static Website Hosting πŸ–₯️

  • What to do:

    • Go to the Properties tab of your S3 bucket.

    • Scroll down to Static website hosting.

    • Enable it by clicking on Enable.

    • In Index document, enter index.html.

    • Optionally, set an Error document (e.g., error.html).

    • Click Save changes.

  • Reason:

    • By enabling Static website hosting, you’re configuring the bucket to act as a web server πŸ–₯️ for your site.

    • The index.html file will be the default page when users visit your website.

Step 5: Set Bucket Permissions πŸ”’

  • What to do:

    • Go to the Permissions tab.

    • Under Block Public Access, click Edit and uncheck Block all public access.

    • Confirm by typing "yes" and click Save changes.

    • This step allows public access to your website files.

  • Reason:

    • By default, AWS restricts public access to your S3 bucket for security. For a static website, you need to make the bucket publicly accessible so users can visit your site 🌐.

Step 6: Set Bucket Policy for Public Access πŸ”‘

  • What to do:

    • Under the Permissions tab, go to Bucket Policy.

    • Add the following policy to allow public read access to the files:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my-static-website-bucket/*"
        }
    ]
}
  • Replace my-static-website-bucket with your actual bucket name.

  • Click Save.

  • Reason:

    • The Bucket Policy specifies who can access the contents of the bucket.

    • The s3:GetObject action allows everyone (Principal "*" ) to read (get) the files in your bucket.

Step 7: Access Your Website 🌍

  • What to do:

    • Go to the Properties tab of the bucket and find the Static website hosting section.

    • You’ll see a URL like: http://my-static-website-bucket.s3-website-us-east-1.amazonaws.com

    • Click on the URL to open your website in a browser.

  • Reason:

    • The URL provided by AWS is the address where your static website is now hosted.

    • You can share this URL with others to let them access your site 🌐.


Conclusion

🎯 Bonus Tip: Reducing Costs in S3 πŸ’°

Looking to cut down on your S3 storage costs? Here’s a simple trick! 🌟 If you’re storing static content in your S3 bucket, you can reduce costs by moving less frequently accessed files to a lower-cost storage class. πŸ—‚οΈπŸ’Ύ

For example:

  • Files that are rarely accessed or where access time isn’t critical can be shifted to S3 Standard-IA (Infrequent Access) πŸ›Œ or S3 Glacier πŸ₯Ά for archival purposes.

  • By leveraging these storage classes, you only pay for what you need while keeping your content accessible when required! πŸ’Ό

Thank you for following along on this AWS S3 journey! πŸš€ I hope you found this tutorial helpful in understanding the fundamentals and practical steps of hosting a static website on S3. 🌐

πŸ’Œ Subscribe to my newsletter to stay updated with more exciting tutorials and tips on AWS and cloud computing! ✨

πŸ’¬ Send me your feedback β€” I'd love to hear your thoughts, suggestions, or questions. Let's grow and learn together! πŸ™Œ

πŸ“š Credits: This blog is enriched with insights from the AWS Official Documentation.

Happy Cloud Building! β˜οΈπŸ”§

Β