Ed Kirk
Ed Kirk

Reputation: 583

Is it possible to setup DNS for s3 using multiple buckets for a single domain?

Is there a way to use another bucket name when hosting a site (or indeed any content) than just www.example.com.s3-region.amazonaws.com? I want to use multiple buckets so that when I update the site I can rollback a version if problems arrise and so that updates are an atomic switch between site versions. I only want one bucket used for a domain at a time.

I.e. something like

Bucket Names:

www.example.com.bucket1
www.example.com.bucket2

Procedure:

www.example.com currently points to -> www.example.com.bucket1.s3-region.amazonaws.com

New site version is uploaded to www.example.com.bucket2.

Once verified DNS is changed so that www.example.com points to -> www.example.com.bucket2.s3-region.amazonaws.com

Upvotes: 2

Views: 450

Answers (1)

Tomas Markauskas
Tomas Markauskas

Reputation: 11596

This should not work because S3 looks at the hostname of the request (www.example.com) to find out what bucket you're trying to access so the bucket has to have the same name.

But it is possible to achieve what you want with Amazon CloudFront. There are two options:

  1. You can create a single distribution and only update the origin of it (the S3 bucket).

  2. You can create two different distributions and update the DNS settings to point to the desired distribution. You would also need to update the CNAME properties in both of the distributions (remove www.example.com from the old distribution and add it to the new one).

Upvotes: 3

Related Questions