When you have the Lightsail instance and the Application is installed on it (for example, WordPress); you can access the application through Lightsail instance’s Public IP Address.
By default, the IP Address is dynamic; that means, there is NO guarantee that the instance has the same Public IP. Whenever the IP Address changed, you will NOT be able to access your Application using the OLD IP Address.
Due to this, you can not configure your website Domain Name to the Dynamic IP address. Whenever the IP address changed you need to re-configure the Domain Name to point to the new IP address. This is NOT the good solution and the Users will frequently loose the access to your website. Which cause a major business loss.
The solution is create a Static IP Address. Static IP addresses are fixed. These will NOT change; so your Application will be accessible through this fixed IP Address without any interruptions.
As it is difficult to remember the IP Address, we normally assign a Domain Name to the Application. Domain Names are easy to remember. How to access the Application using your domain name? We will discuss this through this Article. Assuming you have already registered Domain Name.
Create a Static IP
You must have Static IP Address associated with the Lightsail instance. Static IP Address is fixed, it won’t change and always you can access your Application using this public Static IP Address.
Below are the steps to create the Static IP Address.
Step 1. Login into your Lightsail Console Home page using your Admin account. The management console will display the list of Lightsail instances available.
Step 2. Select the Lighsail instance where you want to create the Static IP address. The console will display more details of the instance and provide the options to manage it.
Step 3. Click on Networking tab. Lighsail console displays list of IP addresses. Each instance has both Public and Private IP addresses.
Public IP address is the IP which is visible to Everyone. Whereas Private IP address is NOT visible to all and it allows you to communicate securely with other AWS internal resources.
Step 4. As I mentioned above, Public IP address is dynamic; that means the IP address is keep on changing dynamically. Due to this, you can not configure your website Domain Name to the Dynamic IP address. Whenever the IP address changed you need to re-configure the Domain Name to point to the new IP address. This is NOT the good solution and the Users will frequently loose the access to your website. Which cause a major business loss.
The solution is create a Static IP; which is a fixed IP address and also visible to Everyone.
Under Public IP there is a button “Create Static IP“. Click on it to create the Static IP.
Step 5. Lightsail console will display “Create a static IP address” page. You need attach the Static IP to the Lightsail instance. Select the instance from the list of instances. If you have only ONE instance created, it automatically attached the instance.
Now you need to assign the unique name to the static IP. You can keep the auto generated name or modify it in “Name your Static IP” field.
Once done, click on Create button to create the Static IP Address.
Now you will see the Static IP address details and it’s attached instance. Note down the IP address.
Another step is create the DNS zone associated with network of the instance. We will get the nameservers and then we map to the domain name to point to the Lightsail instance. Here are the steps.
Create DNS zone
Step 6. From Lightsail console, click on Networking tab. Click on “Create DNS zone” button.
Lightsail console will open “Create a DNS zone” page. Please note that, DNS zones are AWS Global resources. That means, these can reference any instance in any Region.
Enter the domain name under “Enter the domain you have registered” field. Assuming you have the registered domain name.
Click on “Create DNS zone” button. You will see DNS zone details along with DNS records and it’s Nameservers. Note down the nameservers.
Step 7. DNS records details will be displayed under the DNS zone. These records (A, CNAME, MX, NS, SRV, TXT etc,.) are useful to manage the DNS.
Step 7.1. From DNS zone details, click on “+ Add record” button. Lightsail console displays list of available DNS records.
Step 7.2. Select “A record”. This is the place where we will assign the Static IP Address to the Domain Name.
Step 7.3. In Subdomain field, enter the symbol “@” (without double quotes).
Step 7.4. In Resolves to field, select the Static IP Address what we have created in the above step. Once changes done, click on right mark symbol to create the “A record” type.
Step 7.5. Repeat the same steps to create another “A record”. This time in Subdomain field, enter “www” (without double quotes) text.
These steps ensure, your domain name and it’s subdomain name are pointing to the Static IP address. For example, codesteps.com and www.codesteps.com should point to the Static IP address. If you miss to add www.codesteps.com, you will not reach to the website using the URL www.codesteps.com.
Once the DNS zone is created, you will have set of AWS nameservers. These are required to configure in your domain name configuration to point the domain to this Lighsail instance.
Change Domain Name configuration
This can be done from the Domain Registrar where your domain name registered. Change the DNS Settings of your Domain Name to point to the nameservers what we have noted in the above steps.
Once changes done, it will take some time to refresh the entries in the DNS Servers. After some time, verify accessing your website with and without www subdomain. And you will see your website is accessible using the Domain Name.
We will discuss more topics through my Upcoming Articles.