I have been searching solution since last 2 days and tried my best to solve myself, but I think I need help now.
Here is my setup
Problem
When I ping my lightsail instance public/static ip, it works fine.
When I try to ping subdomain.example.com or example.com, I get "Temporary failure in name resolution". I have configured nginx server and I am expecting a page in response to request to my subdomain.
Help will be highly appreciated.
After spending hours of searching and understanding the main cause, I found out the solution.
So the main problem was mismatch NameServer values in Registered Domain, and the NameServer provided by the Hosted Zone.
I purchased the domain from Amazon using Route53. This means my DNS provider is Amazon and it also creates a Hosted Zone for you first time, using which you can create records and define routing. I had deleted the Hosted Zone after domain purchase.
If you delete your hosted zone and recreate later, then you get different DNS setting which mismatches with your First-time created DNS settings.
Later, I created the Hosted Zone again.
Now, here is my current situation.
Look at the RED rectangular sections and you will find out that DNS values are different. This was the main problem
This happens when we delete / create / delete again / re-create the hosted zones but the DNS values remains same in the Domain -> Registered Domains.
Solution: Copy DNS values of Hosted Zone, and update to the Registered Domain section.
Read the reply here, its helpful: https://forums.aws.amazon.com/thread.jspa?threadID=236377
Hope this would help others as well. :)