Skip to content

Instantly share code, notes, and snippets.

@NicolasRitouet
Last active April 25, 2022 11:21
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicolasRitouet/79d49e0e988be042c576 to your computer and use it in GitHub Desktop.
Save NicolasRitouet/79d49e0e988be042c576 to your computer and use it in GitHub Desktop.
Host your static website on AWS S3 and map your custom domain name on Gandi

This tutorial explains how to host your static website on Amazon Web Service S3 with your custom domain name on gandi (or on any other registrar).

Create a bucket on AWS s3 on the closest region (Frankfurt for Europeans).

The name of the bucket should be your domain name: example.com

Enable website hosting

Go to bucket properties, then Static website hosting and select enable website hosting. Index document should be index.html. Click save

Upload the content

Upload the content of your website in your bucket and make the files public.

Get IP of your bucket

Get the endpoint of your bucket (eg. example.com.s3-website.eu-central-1.amazonaws.com) and run ping to get the IP.

ping example.com.s3-website.eu-central-1.amazonaws.com
PING s3-website.eu-central-1.amazonaws.com (54.231.194.51): 56 data bytes

Change the DNS records:

@ 3600 IN A 54.231.194.51
www 3600 IN CNAME example.com.

After a few hours, your domain name should be available (under root domain example.com) and www.example.com should be redirected to example.com.

Next step: deploy from your source control system (bitbucket or github) to AWS S3 automatically

@c0qu1
Copy link

c0qu1 commented Jul 25, 2017

How do I add this DNS record: @ 3600 IN A 54.231.194.51

@caharte
Copy link

caharte commented Aug 10, 2017

Hi, I don't think this will work - S3 can and does use different IPs each time it serves the content from any particular bucket. Each time you ping the bucket endpoint you get a different IP... You need to set something up using route 53 to attach a particular domain name to a bucket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment