Access AWS S3 with wildcard record subdomain

I’m trying to follow this article on cloudflare regarding how to fetch Amazon S3 assets through a subdomain.

It works as expected when I manually define a specific subdomain with DNS like the following:

CNAME ----- assets ------ fullpage.sites.s3-website-us-west-1.amazonaws.com — orange cloud icon

Then I can access my amazon files when using:
https://assets.example.com

However, I want to use a wild card so each subdomain can be redirected to a folder inside my Amazon S3 bucket. I don’t want to manually define those subdomains as that’s something my web users will generate in their web app.

So, I add the following record with the wildcard NAME.
CNAME ----- * ------ fullpage.sites.s3-website-us-west-1.amazonaws.com — grey cloud icon

Notice I wasn’t allowed to use the “orange cloud icon” (Proxied) and I had to use the grey one (DNS only)

Now this URL stopped working as expected:
https://assets.example.com

And I get an aws error:

404 Not Found

  • Code: NoSuchBucket
  • Message: The specified bucket does not exist

What’s going on?

How can I solve this?