Compared to the S&P 500, Amazon (AMZN 1.55%) shares have floundered in 2025. Investors are weighing the company's heavy infrastructure spending against its improving profitability in cloud, ads, and retail, trying to figure out if the company's aggressive investments will pay off or weigh on the business. Over the long term, I believe the former will be true.

The company, which operates a global e-commerce marketplace, a leading cloud-computing platform in Amazon Web Services (AWS), and a fast-growing digital advertising business tied to its e-commerce and media properties, offers investors a way to invest in the artificial intelligence (AI) opportunity via an established company with strong competitive advantages.

Here's a close look at the four key aspects of Amazon's business that arguably seal the deal, making the stock worth buying today.

A group of business people looking at charts on a TV in a conference room.

Image source: Getty Images.

1. Amazon's cloud computing business is a powerhouse

Amazon may be best known for its e-commerce marketplace, but its moneymaker is its cloud computing business, AWS.

In Q2, for instance, AWS contributed more than half of Amazon's total operating income in the period despite representing less than one-fifth of sales. That mix of scale and profitability gives Amazon options. And options are important at a time when the company needs to fund new AI services and continue building fulfillment centers while remaining financially disciplined.

Specifically, second-quarter AWS revenue rose 17.5% year over year to $30.9 billion. The segment's operating income came in at $10.2 billion, or 53% of Amazon's total operating income.

For a company of AWS's size, high-teens growth and an operating margin of 33% from the company's most important business segment are a powerful combination, providing the financial backbone for broader company investments.

2. Advertising is gaining scale

Advertising services have become a second profit pillar. In the same quarter, advertising revenue increased 23% year over year to $15.7 billion. That growth rate notably outpaced the company's overall revenue and largely reflects sponsored products ads. And given that advertising is a higher-margin business than retail sales, this fast-growing business should be very beneficial to the company's bottom line over time.

3. A healthy balance sheet

Amazon's financial strength gives it room to keep investing while weathering macro volatility. As of the end of its second quarter, the company held $93.1 billion in cash, cash equivalents, and marketable securities -- well in excess of its $50.7 billion of long-term debt. That net cash position, combined with trailing-twelve-month operating cash flow of $121.1 billion, supports heavy spending on further AI investments and logistics without straining the balance

4. Prime deepens customer loyalty

Meanwhile, Amazon's Prime customer membership remains a cornerstone of its business ecosystem. While the company doesn't regularly disclose member counts, investors can track "subscription services" revenue -- which includes Prime membership fees along with digital content subscriptions. In the second quarter, subscription services rose 12% year over year to $12.2 billion. Steady growth here suggests Prime continues to attract and retain members, reinforcing high-frequency shopping behavior and creating a captive audience for advertising, Prime Video, and other services.

Prime, which currently costs about $15 per month or $139 on an annual basis in the U.S., bundles fast shipping, exclusive deals, and entertainment, helping keep customers engaged across Amazon's properties. That engagement, in turn, helps support other Amazon segments like third-party seller services and advertising demand, creating a reinforcing flywheel that contributes to revenue diversity and resilience.

Pulling these pieces together -- high-margin revenue from AWS and advertising, a healthy balance sheet, and a sticky Prime ecosystem -- Amazon's diversified set of growth drivers combine to make the business's overall growth profile more resilient.

Of course, shares aren't cheap. But that makes sense for a business like this. Shares currently trade at a price-to-earnings ratio of about 34. Of course, if AWS and advertising continue to grow faster than the overall business, and if AI investments pay off handsomely over the haul, this valuation could look cheap in hindsight.

There are some key risks to consider, including the possibility of a weak macroeconomic environment. This could negatively impact its e-commerce business, AWS, and advertising. It's also worth noting that competition in both cloud and digital ads remains intense. Finally, heavy capital spending for AI infrastructure could take longer than expected to yield returns.

But with two high-margin growth engines and significant financial flexibility, Amazon offers a compelling way for investors to participate in secular trends in cloud computing, AI, and digital advertising -- all while Prime keeps customers coming back. Overall, the stock looks like a buy.