• I have example.com served from idxxxx.cloudfront.net, this goes to S3 bucket nr 1. This works well.
  • I now need subdomain.example.com to also be served from same cloudfront distribution, and point to S3 bucket nr 2. It's a completely different static website hosted on this bucket.

What I tried: I edited origins for my idxxxx.cloudfront.net distribution - I added a new origin there, to point to S3 bucket nr 2, then in Route53 I added this new recordset: Name: subdomain.example.com Type: A - IPv4 Address Alias: yes Alias target: idxxxx.cloudfront.net

The outcome of this attempt: calling subdomain.example.com shows me the contents of S3 bucket nr1 when my intention was to show the content of S3 bucket nr 2 on this subdomain. Is this because for my use case I actually must create another CF distribution? Or can I somehow work with the same distribution?

Maybe useful info - my CF distribution is configured for these CNAMEs: example.com, *.example.com

I also tried adding in Route53 the IPv4 alias that points directly to the S3 bucket nr 2 for subdomain.example.com, and while it works to show me the desired contents of bucket 2, its not retrieved through cloudfront as I actually want it, therefore I dont benefit from things like https and such.

Is my use case impossible with just one CF distribution? Many thanks in advance. Best regards,

  • 1
    I'm posting the answer for the question you've asked... but in case I am missing something, I'll also ask: what is your motivation for using 1 (free) distribution instead of 2 (free) distributions? – Michael - sqlbot Aug 10 '17 at 2:32
  • @Michael-sqlbot because of the cost for having two separate CF distributions :) I thought I could try to use one distribution for both. Please tell me what do you mean by (free) distributions? As I understood, each CF distribution is billed separately. – Amc_rtty Aug 10 '17 at 9:05
  • 1
    There isn't a charge for a CloudFront distribution -- an actual CloudFront distribution itself has no associated cost. You pay a charge per request handled by CloudFront, and a charge per gigabyte of traffic. aws.amazon.com/cloudfront/pricing – Michael - sqlbot Aug 10 '17 at 11:32

It's a completely different static website

A completely different web site needs a completely separate CloudFront distribution. Identical sites with multiple domain names would be the case where you'd serve multiple sites and associate multiple hostnames from a single distribution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.