Amazon (AMZN 0.78%) has gone through a volatile stretch over the last few years. The surge in customers and sales at the pandemic's onset has been followed by decelerating growth and rising costs. Amid all of that was a change in CEOs and a stock split.

But none of the above are reasons to buy. Instead, the green flag I will discuss is the massive customer commitments it has for its lucrative Amazon Web Services (AWS) segment, the primary driver of Amazon's profitability these days.

$89 billion worth of signed contracts

As of March 31, Amazon's web services segment has contracts with customers for a total value of $88.9 billion. In other words, customers are committed to spending $89 billion on Amazon Web Services over the next few years. To put that figure into context, in its most recent quarter (ended on March 31), AWS generated revenue of $18.4 billion. That was a 37% increase from the same quarter in the prior year. What's more, it was an acceleration of the 32% growth it achieved in the same quarter of last year. Note that contractual obligations turn into revenue as customers use the service they agreed to buy.

Significantly, on that $18.4 billion in AWS revenue, Amazon earned an operating income of $6.5 billion. Amazon's other two segments, North America and international, generated an operating loss of $1.6 billion and $1.3 billion, respectively, in the quarter ended in March. These two segments are suffering the effects of economic reopening as consumers spend more of their money at brick-and-mortar retailers. Besides the losses in this most recent quarter, the two segments are notoriously lower-profit-margin businesses.

AMZN Operating Margin (Annual) Chart

AMZN Operating Margin (Annual) data by YCharts

It's great news for Amazon that its more profitable segment is accelerating revenue growth and has a massive backlog of customer demand to fulfill. While its other segments may continue facing headwinds from the economic reopening, AWS continues to thrive. Indeed, the growth of AWS to a more considerable portion of Amazon's overall business has boosted its operating profit margin over the last decade. 

A great time to buy Amazon's stock 

That's creating an opportunity for long-term investors. The market has punished Amazon's stock, which is down 41% off its highs in 2021. Investors are concerned about decelerating growth of retail sales domestically and internationally. However, that might arguably be overlooking where the value comes from in Amazon's stock. AWS is where the bulk of profits will come from, and that segment is accelerating.

AMZN PE Ratio Chart

AMZN PE Ratio data by YCharts

Amazon is trading at a price-to-earnings ratio of 53, near the lowest that investors have been able to buy Amazon stock in the last five years. The worries over its online sales deceleration have created an excellent opportunity for long-term investors to buy Amazon stock -- a green flag, to be sure.