samuraijack
samuraijack

Reputation: 9

How can I use one route53 record to point to two S3 buckets?

I have two buckets a and b with static websites enabled that redirect to original buckets A and B. I created two route53 record sets(A records) slave-1 and slave-2 pointing to each bucket a and b. I then created a Master record set(A record) with failover, slave-1 as primary and slave-2 as secondary. When I try to access the S3 contents using the Master, I get a 404 'No Such Bucket.' Is there a way that I can get this set up to work? If are there are any workarounds for configurations like this?

Upvotes: 0

Views: 254

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 178956

S3 only supports directly accessing a bucket using either one of the endpoint hostnames directly (such as example-bucket.s3.amazonaws.com) or via a DNS record pointing to the bucket endpoint when the name of the bucket matches the entire hostname presented in the Host: header (the hostname my-bucket.example.com works with a bucket named exactly "my-bucket.example.com").

If your tool will be signing requests for the bucket, there is no simple and practical workaround, since the signatures will not match on the request. (This technically could be done with a proxy that has knowledge of the keys and secrets, validates the original signature, strips it, then re-signs the request, but this is a complex solution.)

If you simply need to fetch content from the buckets, then use CloudFront. When CloudFront is configured in front of a bucket, you can point a domain name to CloudFront, and specify one or more buckets to handle the requests, based on pattern matching in the request paths. In this configuration, the bucket names and regions are unimportant and independent of the hostname associated with the CloudFront distribution.

Upvotes: 1

Related Questions