Amazon S3 is a great way to host a static website, but it doesn't support SSL with custom domains and someone may be squatting on the bucket name you need to host your website.
In order to use SSL with a custom domain on S3 you need to also use Cloudfront. Here are the high-level steps necessary to make it all work:
But there are a ton of little details that are required to make all of that work. You need to create an Origin Access Identity to securely wire Cloudfront up to S3. You need to update the DNS record with the correct name servers. The list goes on.
Oh, and you want to do all of this from within your own code? That's really hard.
If you're doing all of this to just host a static website, use Perspect. We've automated it all.
Try it out now.