How to Set Up a Custom Domain or Subdomain for Amazon S3 Static Websites

How to Set Up a Custom Domain or Subdomain for Amazon S3 Static Websites
As a data scientist or software engineer, you may find it necessary to host static websites, such as data visualization projects, or a personal portfolio, on a budget. Amazon’s Simple Storage Service (S3) is a scalable, high-speed, web-based service designed for online backup and archiving of data and applications. S3 allows you to host static websites with a custom domain or subdomain, and this article will guide you through the process.
What is Amazon S3?
Amazon S3 is a storage service that provides object storage through a web service interface. It allows for the storage and retrieval of any amount of data at any time, from anywhere on the web. It is designed to make web-scale computing easier by offering a scalable, secure, and performance-driven storage infrastructure.
Setting up an Amazon S3 Bucket
Before we dive into how to customize your domain or subdomain, it’s important to understand how to set up an Amazon S3 bucket.
- Sign in to the AWS Management Console and open the Amazon S3 console.
- Choose ‘Create bucket’.
- In the ‘Create bucket’ wizard, provide a DNS-compliant name for your new bucket. The bucket name will be part of the default URL that S3 assigns to your website.
- Choose the AWS Region where you want the bucket to reside.
- Leave all other default settings and choose ‘Create bucket’.
Hosting a Static Website on S3
To host a static website on S3, you need to enable the website hosting feature on your bucket.
- In the Amazon S3 console, choose the bucket you’ve just created.
- Choose the ‘Properties’ tab.
- Choose ‘Static website hosting’.
- Choose ‘Use this bucket to host a website’ and specify the ‘index.html’ as your index document. If you have an error page, specify it as well.
- Note down the endpoint URL that S3 provides. This will be your default website URL.
Setting up a Custom Domain or Subdomain
Once your website is hosted, you can set up a custom domain or subdomain using Amazon Route 53, AWS' DNS web service.
- Sign in to the AWS Management Console and open the Route 53 console.
- In the navigation pane, choose ‘Hosted zones’.
- Choose ‘Create hosted zone’ and input your domain name.
- After the hosted zone is created, create a new record set.
- In the ‘Name’ field, specify the subdomain if you want to use a subdomain.
- For ‘Type’, choose ‘A - IPv4 address’.
- For ‘Alias’, choose ‘Yes’. In ‘Alias Target’, choose your S3 website endpoint.
- Choose ‘Create’.
Configuring DNS Settings
You’ll need to configure your DNS settings with your domain registrar.
- Go to your domain registrar’s website and sign in.
- Navigate to the DNS settings page.
- Replace the existing name servers with the name servers from Route 53.
Once these steps are completed and the DNS changes propagate across the internet (which may take up to 48 hours), your S3 website will be accessible from your custom domain or subdomain.
Amazon S3 provides a convenient, cost-effective solution for hosting static websites. Coupled with Route 53, you can customize your website’s URL to use a domain or subdomain of your choice. This setup is ideal for personal projects, portfolios, or small business websites.
Conclusion
In this article, we walked you through Amazon S3, how to set up an S3 bucket, host a static website, and configure a custom domain or subdomain. We hope you found this guide useful as you venture into hosting your static websites on Amazon S3 with custom domains or subdomains.
Remember, a well-chosen domain or subdomain can make your site easier to find and lend it an air of professionalism. Always select something that reflects your brand and is easy for your users to remember. Happy hosting!
Key Points: Amazon S3, Hosting static websites, Custom domain or subdomain, Amazon Route 53, DNS configuration.
About Saturn Cloud
Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.