DEV Community

Cover image for Hosting a Static Website on S3, Versioning, Lifecycle Configuration, Cross-Region Replication (CRR).
Glory Ugochukwu
Glory Ugochukwu

Posted on

Hosting a Static Website on S3, Versioning, Lifecycle Configuration, Cross-Region Replication (CRR).

Steps to host a static website on S3 and Necessary features configurations.

Here's my experience hosting a static website on Amazon S3 and configuring essential features like S3 Versioning, Lifecycle Configuration, and Cross-Region Replication (CRR). These configurations enhance data management, optimize costs, and ensure high availability.

Brief Summary of S3 before the steps

Amazon S3: (Simple, Storage, Service).The Hard Drive of AWS Stores, Retrieve and Scale effortlessly. AWS S3 is a scalable and secure cloud storage solution offered by Amazon Web Services, it allows you to store and retrieve any amount of data, at any time, providing durability, high availability, and low latency.

Use Cases

  1. Hosting Static websites e.g (blogs, product catalogs)
  2. Backup and recovery.

Hosting a Static Website on S3

Amazon S3 allows you to host static websites efficiently without managing servers. This is useful for personal portfolios, documentation sites, or company landing pages.

Steps to Host a Static Website on S3:

Step 1: Create an S3 Bucket

  • Open the AWS S3 Console.
  • Click Create Bucket.
  • Enter a unique bucket name.
  • Turn off "block all block access"
  • Enable bucket versioning
  • Choose a region and leave the default settings.
  • Click Create Bucket.

S3 Bucket successful created

Step 2: Upload Website Files

  • Open the bucket and navigate to the Objects tab.
  • Click Upload and add your index.html, error.html, and other necessary files.

Where to upload your files

uploading your file

Here are the files that I uploaded.

uploaded files on my S3 bucket

Now, let's run some configurations.

Step 3: Enable Static Website Hosting

Go to the Properties tab.
Scroll to Static website hosting and click Edit.
Choose Enable.
Set index.html as the Index document.
Click Save Changes.

Enabling Static website property features

Step 4: Set Public Access Permissions

  • Navigate to the Permissions tab.
  • Click Block Public Access and disable all restrictions.
  • Edit the Bucket Policy to allow public access and add your bucket name.
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::arn:aws:s3:::aws-s3-glory/*"
            ]
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode
  • Click Save Changes.

Step 5: Access Your Website

  • Go back to the Properties tab.
  • Copy the Static website hosting endpoint.
  • Open it in a browser to see your hosted site.

And here's our (my first static website with S3)Website.

My first static website with AWS S3

Versioning & Enabling S3 Versioning

S3 Versioning allows you to keep multiple versions of an object, preventing accidental deletions or overwrites.

Steps to Enable Versioning:

  • Open your bucket in the S3 Console.
  • Go to the Properties tab.
  • Click Edit under Bucket Versioning.
  • Select Enable and click Save Changes.

    Key Considerations:

Each object version is stored separately, which may increase storage costs.
Suspending versioning stops new versions from being created but retains existing ones.

Lifecycle Management:
Transition Action: This enables you to move objects between different storage classes based on a defined schedule. S3 will automatically remove all objects within a bucket when a specified date or time in an object's lifetime

Configuring Lifecycle Policies

S3 Lifecycle Configuration helps you manage object storage by transitioning data to different storage classes or automatically deleting them.

Steps to Create a Lifecycle Rule:
Here's a step-by-step guide on how to implement lifecycle management within your bucket:

  • Navigate to your bucket and choose the "Management" tab.
  • Click Create lifecycle rule.
  • Enter a rule name and define the scope of its application.
  • Configure Transition actions, such as:
  • Move objects to S3 Infrequent Access (IA) after 30 days.
  • Move objects to Glacier after 90 days.
  • Configure Expiration actions, such as deleting objects after a set period.
  • Click Create rule.

Use Case: Automatically move older website logs to Glacier to save costs.

Setting Up Cross-Region Replication (CRR)

Cross-Region Replication ensures your data is automatically copied to another region, improving disaster recovery and availability.

Steps to Configure CRR:
Enable Versioning on both source and destination buckets.
Go to your source bucket’s Management tab.
Click Replication rules > Create replication rule.
Define a rule name and select a destination bucket in a different region.
Select an IAM Role (create a new one if needed).
Click Save Changes.

Considerations:
Replication applies only to new objects after enabling CRR.
Data transfer and storage costs apply to replicated objects.

And that's all for my first hands-on on S3.

Challenges Faced & Solutions I encountered few challenges while on this,

  • Replication Delays: CRR does not replicate old files. To fix it, I had to re-upload important objects after enabling replication.

How This Task Contributes to My Learning & Career Growth
Configuring S3 for static website hosting and data management provided me with hands-on experience in cloud storage optimization, cost management, and disaster recovery. These are essential skills for any aspiring Cloud professionals.

Through this task, I also gained deeper insights into AWS best practices, which will be valuable in enterprise-level cloud deployments.

Conclusion

Amazon S3 offers powerful capabilities beyond simple storage. By implementing Versioning, Lifecycle Rules, and CRR, you can enhance data durability, cost efficiency, and high availability.

I highly recommend experimenting with S3’s configurations. Understanding these features will strengthen your cloud expertise and prepare you for real-world scenarios.

Happy learning my fellow learners!

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.