12
votes

I'm trying to host a simple static website from my AWS account with S3. I had an old dusty account with lots of strange settings from testing over the years, I also had an S3 account with a 'mypersonaldomain.com' and 'wwww.mypersonaldomain.com' bucket. Anyways I wanted to start fresh so I canceled the account to start new.

Now when I go to create a 'mypersonaldomain.com' and 'www.mypersonaldomain.com' it says the bucket name is taken even though the account was deleted a while ago. I had assumed that amazon would release the bucketname back to the public. However when I deleted the account, I didn't explicitly delete the buckets beforehand.

I'm under the impression to use S3 for static website hosting the bucket names need to match the domain name for the DNS to work. However If I can't create a bucket with the proper name is there anyway I can use S3 for static hosting? Its just a simple low traffic website that doesn't need to be in an EC2 instance.

FYI I'm using Route 53 for my DNS.

[note 'mypersonldomain.com' is not the actual domain name]

3

3 Answers

18
votes

One way to solve your problem would be to store your website on S3 but serve it through CloudFront:

  1. You create a bucket on S3 with whatever name you like (no need to match the bucket's name to your domain name).
  2. You create a distribution on CloudFront.
  3. You add an origin to your distribution pointing to your bucket.
  4. You make the default behavior of your distribution to grab content from the origin created on the previous step.
  5. You change your distribution's settings to make it respond to your domain name, by adding a CNAME
  6. You create a hosted zone on Route 53 and create ALIAS entries pointing to your distribution.

That should work. By doing this, you have the added benefit of potentially improving performance for your end users.

Also note that CloudFront has been included in the Free Tier a couple months ago (http://aws.amazon.com/free).

11
votes

In my opinion, this is a tremendous design flaw in the way that S3 requires that bucket names are universally unique across all users.

I could, for example, make buckets for any well known company name (assuming they weren't taken) and then the legitimate users of those domains would be blocked from using them for the purpose of creating a static s3 website if they ever wanted to.

I've never liked this requirement that s3 bucket names be unique across all users - a major design flaw (which I am sure had a legitimate reason when it was first designed), but can't imagine that if AWS could go back to the drawing board on this that they wouldn't re-think it now.

In your case, with a delete account, it is probably worth dropping a note to s3 tech support - they may be able to help you out quite easily.

1
votes

I finally figured out a solution that worked for me. For my apex domain name I am using CloudFront which isn't an issue that someone already has my bucket name. The issue was the www redirect. I needed a server to rewrite the URL and issue a permanent redirect. Since I am using Elastic Beanstalk for my API I leveraged Nginx to accomplish the redirect. You can read all the details on my post here: http://brettmathe.com/aws/aws-apex-redirect-using-elastic-beanstalk/