is creating a cloudfront distribution for every users a bad idea

I’m looking for a scalable solution for my users to upload some static files that I would host for them.
I’m thinking one s3 bucket with a ‘folder’ per customer. and then creating a CF distribution for every customer so they would all get a different domain.

I see AWS has an increasable quota of 200 distributions, but im worried it could be a bad design to create a distribution for each of them once I reach 10000 distributions

Thanks for the response, if I go with a single CF, I need to add a CNAME for every customer (aws seems to have a limit of 100 cname per CF) or is there an other way?

I can’t go for a url based redirect, because they would have to share localstorage

holy shit the cost alone would be

just

lol

how so ?

I think that’s a fine solution.

Alternatively, you can use a wildcard CNAME for subdomains, i.e., *.example.com.

hmm for some reason I thought that each cloudfront had an hourly cost associated with it (the way load balancers do), in addition to the usage fees

indeed it does not :slight_smile: I liked the thought experiment of OP.

btw /u/gautier_ if you have paid suport, can you ask them your use case ? I’d be curious to know if your use case could genuinely allow you to have, say, a soft limit upgraded in the multiple thousands or not

I don’t have paid support unfortunately, if I get it at some point i’ll ask :slight_smile:

I’m not expert on CF, I didn’t know you could have wildcard subdomain in CNAME !
so if I can use 10k subdomains on the same CF and redirect to different folder on s3 based on the domain that would work !
Thanks /u/SnooBooks7891 and /u/digitizemd I’ll try this

It should be simpler to have a example.com/user/ way of redirecting users instead of a user.example.com, at least from the point of view of CF or DNS.

Wildcard is one way to go. Most places doing what you’re doing will instead have a media.companyname.tld (or static, or images or whatever in place of media) type domain though, because juggling CNAMES etc ultimately turns into a whole ton of tech debt and extra things you have to monitor.

np. I think it’s a pretty common pattern to have a setup like with a public ALB fronting an nginx cluster who will use the subdomain of the $host to create headers for downstream applications behind private ALBs to make use of.

My company have several thousands Cloudfront instances, 1 per domain name (not subdomain but really different domains), use case is for a SaaS where customers can connect their own domains.
It was not an issue for aws to raise the limit to 10k

We also create one CloudFront distribution per domain/subdomain. We made the mistake early on to put multiple domains on the same distribution, but then we couldn’t customize behaviors per domain and the metrics weren’t separated by domains.

What if you used a single distribution and had the ALB direct the user to a specific s3 bucket based on the url path. For Example:

URL:xxxxxx.domain.com/username
ALB redirects to s3: username-xxxxxx-domain-com

Or even use a single s3 bucket and restrict user access to their prefix.

May I ask how SSL works in that scenario?

So you just need an upload portal? Is there a reason why it has to have the customer’s name instead of just them uploading to your company name?

Just trying to understand the need for all the unique domains.

I think that is true, /u/ImNotACachivache.

AWS gives you free ACM certificates. With DNS validation, renewal is fully automatic, too.

Each Cloudfront instance have it’s own certificate created in ACM