Was this article helpful?
Thanks for your feedback
Amazon Simple Storage Service, or simply Amazon S3, is a scalable, web-based cloud storage service offered as part of Amazon Web Services.
It is used for backing up data and applications online. Besides, it also provides a provision to host or deploy a static website. In this guide, we will look at the steps required to host a static website on Amazon S3.
Deploying a website on S3 is a 4-step procedure:
Note: Before we start, it is assumed that you already have a website running on the localhost with Gatsby as the front-end and Contentstack as the back-end. We suggest you follow the steps mentioned in the Build a Sample Website Using Gatsby and Contentstack and get your website ready.
If you followed the above tutorial, you should have your website running on localhost, port 8000. Now that it is ready, let's deploy it on S3. For that, you need to create an account in AWS with S3 services enabled.
Note: You need to create an IAM account with administrative permissions so that you are able to create an access ID and secret key within your AWS console.
With these steps, we have set up the account and are ready with the essentials. Let's now move ahead and install the Amazon CLI and configure it.
Follow the steps given below to install AWS CLI on Ubuntu and Windows:
sudo apt install awscli
aws --versionAfter running the above command, it will display the installed version of the AWS CLI on your system. If you have python installed on your machine, you can also install it using the following command:
pip3 install awscli
Note: Before running the above command, ensure you have Python 3 and pip3 installed on your machine. For more information on Windows installation, refer to AWS docs.
aws configure
With these steps, we have configured the AWS CLI.
A bucket in S3 is basically cloud storage that will host your website data. Proceed with the steps given below to create a bucket:
Now that you have created a bucket, let's move ahead and host your Gatsby site on S3.
Before deploying the website make sure you have the website running in a browser on localhost:8000. So the AWS access to it is sorted out.
You must have also downloaded the code from the sample app page. Now follow the steps given below:
npm i gatsby-plugin-s3
{ resolve: `gatsby-plugin-s3`, options: { bucketName: "mention your s3 bucket name here", }, },An example is shown below. You may refer to the Gatsby S3 Plugin guide for more detail.
Additional resource: For more information on deploying Gatsby sites on S3, refer to Gatsby docs.
Was this article helpful?
Thanks for your feedback