0

I know it's possible to have a subdomain point to an s3 bucket (so, I could use something like s3.example.com). Is it possible to use wildcard DNS with S3 (or something like it) to do the following?

  • abc.example.com => /abc.example.com/
  • 123.example.com => /123.example.com/
  • 123.example.com/test.png => /123.example.com/test.png

I'm assuming this isn't possible with S3; I can use any similar service. It just needs to be able to serve static files.

(Note: I'm making a file host, where people can sign up for their-subdomain.my-host-domain.com. The host would just serve static files from their subdomain on my domain.)

Gregory
  • 103
  • 1

2 Answers2

0

I'm assuming that you would create separate S3 buckets for each subdomain. You would need your DNS server to have a wildcard record, but where the requested name is prepended to the response. For example, the following domains would be dynamically generated:

abc.example.com.    CNAME   abc.example.com.s3.amazonaws.com.
123.example.com.    CNAME   123.example.com.s3.amazonaws.com.

I don't however know of any DNS servers which have this functionality.

mgorven
  • 30,615
  • 7
  • 79
  • 122
0

S3 requires the bucket to exist in the first place... so without a bit of work, the short answer is that it can't be done out of the box.

To do it though.. 1. When a user signs up - use the AWSSDK to create an s3 bucket with the slug at the front... (ie - company.example.com) 2. Configure the bucket using the AWSSDK to allow static file hosting 3. Add a record to Route53 as an alias from company.example.com to the appropriate s3 bucket.

Then you've got to configure all the permissions issues as well - who can access etc - using IAM and s3 policies. Fair bit of work.

Pete - MSFT
  • 101
  • 2