Every once in a while we get a request to create a new URL and redirect the old URLs to point to the new ones. Ah!!! I get the frustration, but, once you get your hand’s dirty, you won’t be able to stop your excitement. Let’s get the ball rolling.
If you have dealt with WebServers, you must already know that we use redirect rules in the configuration file to serve this purpose. But in AWS, there are a couple of steps for you to do to accomplish this.
Note – I would strongly recommend automating (IAC Model) for this process. Believe me, you want this 😉
Use case – Let’s redirect website1.com to website2.com
Here we go, with the steps of redirection
- Create an S3 bucket and enable static website hosting pointing to DNS website2.com
- Create a CloudFront distribution
- Whose ‘Origin Domain Name’ points to the static website URL from the previous step. (ex – <example>.s3-website.ca-central-1.amazonaws.com)
- Alternate Domain Names must be website1.com
- Add the related SSL cert
- Now create a route53 alias record for website1.com that points to the CloudFront distribution from the previous step
ALL DONE!!
Automate this and make your life simpler ☺️