Firstly,
- Create bucket
- Enable website on bucket
- Change bucket policy
- Upload index document
- Domain DNS settings
Log in to the Amazon S3 Management Console
Create bucket
if you haven’t done so already, you’ll need to create a bucket.
This bucket needs to be the same as your URL you want to host.
For example mydomain.com
Enable website on bucket
Right click on your newly created bucket and select properties.
Select the Website tab.
Ensure enabled is ticked, and enter the name of your index (default) document.
Change bucket policy
You need to change the bucket policy to enable public viewing of the contents.
{ "Version": "2008-10-17", "Id": "0fc0b0d1-8e11-45f8-9851-a49af3bfb649", "Statement": [ { "Sid": "PublicReadForGetBucketObjects", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::mydomain.com/*" } ] }
Upload index document
You then need to upload this document to the bucket.
You can do this directly in the AWS Console, or by using any number of S3 clients.
Test your “website” by going to the Endpoint listed. In the example above, it would be:
http://mydomain.com.s3-website-us-east-1.amazonaws.com/
It should display your default document you uploaded above.
Domain DNS settings
Take a note of the “Endpoint” URL in the website configuration tab.
In our example, it’s http://mydomain.com.s3-website-us-east-1.amazonaws.com
You will need to setup a CNAME on your domain to map www.mydomain.com to www.mydomain.com.s3-website-us-east-1.amazonaws.com
And that should be it!
Leave a Reply