0

I have a question about how DNS works in conjunction with AWS s3 buckets that I am trying to understand. I have a modest knowledge about DNS and AWS, but I don't understand why my routing solution didn't work as I expected it to. I am a master class coder, but my networking knowledge is just sufficient to get me into trouble.

I have a domain that I have hosted in route53 (let's call it foo.com), and I created a s3 bucket to host a static website and mapped the domain to the bucket. I wanted to make sure that www.foo.com also landed there, so I created a CNAME to map www.foo.com to foo.com. I would expect that this would cause requests to the www subdomain to land on the bucket, but it does not.

I went to look up a tutorial, and the pattern that AWS recommends is to create a second s3 bucket called www.foo.com, and redirect incoming calls to the foo.com bucket, and then create an A record in DNS to point to the www.foo.com bucket.

I did this and everything more or less works (bucket path is shown in the URL, ick), but I am curious why my solution didn't work. It seems like it is slightly simpler. Am I missing something obvious? Mapping subdomains via A records make a lot of sense if I want to server differing content / S3 buckets for each subdomain, but if I am just trying to map www requests back to the root, the CNAME solution looks cleaner.

Bonus points: Should I just be using Cloud Front to manage this? It looks slightly more complicated / expensive, so I haven't really looked into it too much yet. I wonder if AWS is using this odd looking bucket redirection pattern because they really expect people to be using something more nuanced for routing, like CF.

1
  • Yes, use CloudFront. CloudFront has a generous amount of free bandwidth per month, more than S3 / the rest of AWS, and you can change the domain / URLs more easily.
    – Tim
    Oct 5 at 18:19

0

You must log in to answer this question.

Browse other questions tagged .