Search code examples
amazon-web-servicessubdomainaws-api-gatewayamazon-route53wildcard-subdomain

AWS Route 53 wildcard subdomain with Api gateway


I have a Hosted zone name example.com on AWS Route53 DNS service. I have multiple subdomain record sets like:

api.example.com - type A - ALIAS xxx.cloudfront.net
www.example.com - type A - ALIAS xxx.cloudfront.net
app.example.com - type A - ALIAS xxx.cloudfront.net

All the records point to a Cloudfront generated by Api Gateway Custom Domain.

I want to offer a custom subdomain to all of my users:

USERNAME.example.com
alice.example.com
bob.example.com
...

I do not know in advance the username of all my users and there can be 1000s of them.

How can I setup Route53 to route all non defined subdomains to a specific Cloudfront => Api Gateway => AWS Lambda instance?


Solution

  • Wildcard custom domains are now supported by AWS API Gateway.

    https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html#wildcard-custom-domain-names