This is an excellent question. And it sounds as if you are taking a very businesslike approach to owning your next home, which is something I strongly encourage.
I wish it were not true, but there is a real danger that home prices in an overheated market like this one could retreat if inventory stabilizes, if we have another recession (which we will sooner or later), if investments like stocks stagnate/fall, or if interest rates rise significantly.
In your case, you mention two years as a minimum. This time frame is always a little risky because it costs considerably more to sell a house than to buy. These costs should be worked into your equation.
However, if your minimum expected time of ownership is a bit longer than two years, and if your choice is between renting and owning, then I would suggest you consider how much money renting will cost when compared to the financial costs and benefits of owning.
If you work your numbers carefully, you may find that ownership will be a better financial option even if you have to sell the home for a little less when you move. This is because some of your mortgage payments go toward equity, your payments will not rise during ownership (if your rate is fixed) and your interest is tax deductible. But don't forget you will have other expenses while you own, including taxes, insurance and maintenance. It all should go into your math.
One other note: if you are indeed looking at a five-year maximum time frame, you definitely should consider a variable rate mortgage with a fixed five- or seven-year rate at the beginning. This can lower your payments a lot during the first years or seven years.
Please let me know if you have any questions!
Cherry Creek Properties LLC