I am migrating my API from a provider to AWS.
I have a TTL of 30 seconds for the A Record, so I know that for 30 seconds the old ip will be fetched by the browser etc.
I want to be notified at the starting of this 30 seconds TTL in order to stop serving new api requests and make the migration a zero error one.
How can i get to know the exact moment of switch from previous provider ip to AWS ip?
You cannot in any practical sense.
You are misunderstanding how DNS works. DNS consists of a globally replicated system that resolves DNS names to IP addresses (at its basic level). How long does this replication take, varies. Can I count on replication, eventually. Can I manage or control this replication, no.
The TTL is the Time To Live value. This is a recommendation not a requirement. This value is not respected by a lot of DNS resolvers. A typical TTL is measure in hours, days or weeks. Not seconds. Many clients will just ignore a short TTL.
What is the best practices approach if you want near zero downtime? You replicate your services so that both the old DNS enteries and the new DNS entries work. Expect this to take several days not several seconds.
If you are also moving your records (registration) to AWS then add a day or two extra. All of the registrars will tell you that the process can take days to finalize. There is also the risk (which has happened to me several times moving away from Network Solutions to Route 53) that the transfer request is revoked at a later date. Even after paying AWS and renewing the records, the domain jumped back to Network Solutions for some "unknown" reason weeks later.
In my best practices I inform my customers to plan on 30 days for mission critical systems.