In this article, we will learn how to map a Domain Name Server(DNS) with Amazon Web Services(AWS), along with registering domain on Route 53, managing Load Balancer using EC2 instance and creating a free SSL Certificate for our domain from AWS Certificate Manager.
To this extent, I have outlined below the necessary few steps:
1: Purchase Domain (we’ll go with Godaddy, you prefer any service provider)
2: AWS EC2 Create
3: AWS Route 53
4: GoDaddy DNS set up with AWS nameserver
5: AWS Certificate Manager
6: AWS EC2 Load Balancer
7: Redirecting HTTP to HTTPS from AWS EC2 Load Balancer
8: Map Load Balancer with Route 53
Step 1: Purchase Domain
To integrate your GoDaddy domain with AWS you need a valid domain ( eg: mydomain.com), you can purchase your domain from GoDaddy.
Step 2: AWS EC2 Create
Also, you need an AWS account to deploy your project on AWS by creating an EC2 instance, follow this link: Project Deployment on AWS with CI/CD and GitHub. From this link, you’ll get an IP address from the EC2 instance that we’ll map with GoDaddy.
Step 3: AWS Route 53
Open AWS and search Route 53. In Route 53 you’ll get 4 options these are DNS Management, Traffic Management, Availability Monitoring, and Domain Registration. We already purchase a domain from GoDaddy so we need to choose a DNS Management option and Create hosted zone by entering such details.
Domain Name: mydomain.com that you purchased from GoDaddy
Description — Optional: you can write some information about your domain
Type: Public hosted zone
and click on the create hosted zone button
After creating a hosted zone you will get a success message that mydomain.com was successfully created.
Now we need to add 2 types of records to the current hosted zone, Type A and Type CNAME click on the Create record button and enter such details to create Type A:
Routing Policy: Simple Policy
Record Name: (left it blank)
Record Type: A- Route traffic to an IPv4 address and some AWS resources
Value: EC2 instance IPv4 address
after entered such details click create records and you will get a success message and a new record has added to the hosted zone.
After added Type A record in the zone, click on the Crate records to add Type CNAME record to our list and enter such details:
Routing Policy: Simple Routing
Record Name: www
Record Type: CNAME — Routes traffic to another domain name and to some AWS resources
after entered such details click on Create records and again you will get a success message and a new record has added to the hosted zone.
Step 4: GoDaddy DNS set up with AWS nameserver
Now go to the domain server provider site and points to the Type CNAME server name on the domain mydoomain.com by selecting I’ll use my own nameservers.
Step 5: AWS Certificate Manager
Now you need to generate a free SSL Certificate for your domain that you generated on your service provider site (eg: GoDaddy).
link: Create a Free SSL Certificate Manager on AWS
After creating the certificate wait for few minutes for successful validation of your certificate.
Step 6: AWS EC2 Load Balancer
Now we are creating a EC2 load balancer to redirect http to https it’ll also balance our SSL certificate request, click on Create Load Balancer button to create a new load balancer or choose existing one on which which you want to redirect SSL certificate.
After clicking the Create Load Balancer button on the next page you’ll see 3 options: Application Load Balancer, Network Load Balancer and Classic Load Balancer.
a) Configure Load Balancing: select Application Load Balancer
b) Configure Security Setting: In this security setting provide the name of the load balancer, Scheme, IP address type.
Click on the Add Listener button and add HTTPS (Secure HTTP) protocol that will help to redirect http to https.
Select all Availability Zone and click on the next Configuration Security setting button
from the next page choose certificate type: Choose a certificate from ACM
certificate name: AWS Certificate Manager(choose your certificate) and click on Next:Configure security group button
c) Configure Security Group: Now either select security group or create a new security group, I recommanded that you choose security group from your list and click on Next: Configure Routing button
d) Configure Routing: In the configure routinng give the name of the Target group and click Next: Register Target to register the target to the EC2 instance.
e) Register Target: From here choose your EC2 instance and click on Add to registered button to registered EC2 with Load Balancer.
f) Review: The final step of load balancer is to review all the setting and click on Create button to create a Load Balancer.
Step 7: Redirecting HTTP to HTTPS from AWS EC2 Load Balancer
After created EC2 Load Balancer your domain will work on both http and https but when you http://mydomain.com in the url it’ll not redirect you at the https://mydomain.com url, to do this select the listener and choose Listeners from bottom menu options, choose HTTP: 80 listenerID and click on the View and edit rules.
Click on Edit Option to edit this configuration.
from the + Add action you will get three options: Forward to, Redirect to and Return fixed Response…
from there select Redirect to option
After doing some changes left every as well, that will redirect to the original path and click on the submit button and update button at upper side for updating all changes made by you.
Step 8: Map Load Balancer with Route 53
The last step is to map load balancer configuration with Route 53. To do this you need to edit Type A record from the Route 53 hosted zone.
After clicking this edit button do some small changes like:
Value/Route traffic: at Alias to Application and classic Load Balancer
Choose Specific region: Choose your region
Choose Load Balancer: Choose Load Balancer that you created earlier in EC2 instance
Now Click on Save Changes wait for few minutes.
Hey you have Successfully Integrated your GoDaddy domain with AWS Route 53. Congratulation :) :)
Congratulation you have successfully setup you domaon with AWS EC2 instance and route the EC2 IP address with your domain with a free SSL certificate, If you like this article please leave a clap for me.
Thank You. :)