Reputation: 2078
I have a bucket called subdomain.domain.com
that hosts code that should be used whenever users go to various subdomains.
e.g. going to:
- a.domain.com
- b.domain.com
- c.domain.com
Should go to the same bucket.
I've set the CNAME for all the subdomain URL's to go to the URL of the subdomain.domain.com
bucket. The problem is that, AWS tries to look for bucket a.domain.com' instead of just going to
subdomain.domain.com' bucket
I've read some suggestions saying I can create a bucket like a.domain.com
and have it redirect back to subdomain.domain.com
but I don't want a URL change and I'd like to be able to upload just to one bucket and all subdomains will be updated.
Upvotes: 2
Views: 1746
Reputation: 178966
Some features that appear to be "missing" in S3 are actually designed into CloudFront, which complements S3. Pointing multiple domain names to a single bucket is one of those features. It isn't possible to do this with only S3 since, as you noticed, S3 matches the hostname with the bucket name.
Create a CloudFront distribution, defining each of the desired domain names as Alternate Domain Names.
For the origin server, type in the web site endpoint hostname of the bucket, found in the S3 console. (Don't select the bucket from the dropdown list).
Point the various hostnames to CloudFront in DNS.
CloudFront will translate the incoming hostnames so that S3 serves all the domains from a single bucket, the one you specified as the origin server.
Note that this configuration also allows you to optionally use SSL with your web hosting buckets, which is another feature that S3 relies on CloudFront to implement.
Upvotes: 8