Few of the big tech stocks have gotten a cold shoulder from investors more than Amazon (AMZN -1.07%). Thanks to the company's massive unprofitability in 2022, many investors tossed it aside due to its spending habits. However, that trend is starting to reverse itself thanks to CEO Andy Jassy's efficiency measures.

Second-quarter results were fantastic for Amazon and included a significant rise in profitability, something investors love to see. But is Amazon a buy after its latest quarter? Let's find out.

This is not the Amazon of old

Amazon is so much more than the e-commerce investment it used to be. Thanks to various product developments, Amazon also has other segments like Amazon Web Services (AWS), advertising, and third-party seller services. In fact, these segments have become the primary reasons to invest in the stock, as the online store most customers are familiar with is hardly growing.

Segment Q2 2023 Revenue YOY Growth
Online stores $53.0 billion 4%
Third-party seller services $32.3 billion 18%
AWS $22.1 billion 12%
Advertising services $10.7 billion 22%
Subscription services $9.9 billion 14%
Physical stores $5.0 billion 6%
Other $1.3 billion 26%

Data source: Amazon. YOY = Year over Year.

If you're familiar with Amazon as an investment, one thing stands out from this table: AWS' disappointingly low growth. AWS used to be Amazon's growth engine, but this division has suffered immensely because clients are attempting to become more efficient with their cloud spending.

Fortunately, other segments like advertising and third-party seller services have picked up the slack and allowed Amazon to grow at an 11% clip this quarter.

As mentioned above, profitability significantly improved, as Amazon's operating expenses only rose 7.5% in Q2. Because it grew expenses more slowly than revenue, its operating margin expanded from 2.7% to 5.7%. That's a significant improvement and was the primary reason Amazon beat analysts' expectations. This beat caused Amazon's stock to rise nearly 8% following earnings.

But after that rise, is it still worth buying?

Amazon's margins have improved, but its valuation hasn't followed

Higher-margin businesses usually demand a higher price-to-sales (P/S) valuation premium. These companies can produce greater profits because they don't need to spend as much on the product itself. This is captured through the gross margin metric. Amazon's gross margin has risen significantly over the past few years thanks to the rise in its higher-margin businesses like advertising and AWS.

AMZN Gross Profit Margin Chart

AMZN Gross Profit Margin data by YCharts

However, its P/S ratio hasn't followed suit and has remained around the same level as in 2016, when its gross profit margin was substantially less than what it is now. Because of that, I think Amazon has three catalysts going for it. One, its increased profitability will get investors excited about the stock again. Two, its valuation level is at a low point, which is something other big tech investments cannot claim. Third, AWS should return to rapid growth mode when economic sentiment picks up.

But why the optimism on AWS when it has struggled recently? It all comes down to the market potential. Mordor Intelligence (and many other market research companies) expects the cloud computing market to generate about $580 billion in 2023. However, it projects that market to massively expand by a 16.4% compounded annual growth rate to $1.24 trillion by 2028. With Amazon holding an impressive 32% market share in the cloud space, it's in a strong position to capitalize on that growth.

As a result, I think Amazon is a fantastic buy after its phenomenal quarter. While it would have been better to buy the stock at the beginning of 2023, it's still a good choice. Fortunately, there is plenty of upside ahead, and getting in now allows investors to capitalize on a likely multiple expansion that's to come.