Domain redirection with CloudFront functions
This article is about me ranting on how a simple domain redirection from apex (root) domains to other domains or subdomains can become a tricky one, given the official AWS proposed solutions in the matter.
I will present a number of well established, yet cumbersome solutions, together with a much a simpler alternative which leverages CloudFront functions instead.
The “Problem”
Lately stumbled upon (again) on an apparently simple problem which I already faced many years ago:
I want to redirect internet traffic from my root (apex) domain (for instance, example.com) to another domain/subdomain (for instance, example.net, www.example.com). How can I do this?
I still remember it as a very odd experience, given the nature of the official solution. After many years, with big surprise, the solutions still involve:
- Creation of a S3 Website hosting bucket with Redirection request to another bucket or domain — why do I need an S3 bucket to perform domain redirection?