Let's be clear. Artificial intelligence, or AI, is a massive opportunity, and there are hundreds of excellent companies that should benefit from this technology revolution. There are chipmakers, software developers, data center operators, and many more that should be big winners from the surge in AI investment.

Having said that, if I were to choose just one stock to invest in AI, it would have to be Amazon (AMZN -0.32%). It offers an excellent combination of growth potential and safety, and there's a solid case to be made that it is the most attractively valued of the megacap tech stocks right now.

Amazon's e-commerce business could leverage AI

Amazon's e-commerce business is so big that it is larger than its next 10 competitors combined. And despite the massive scale, it continues to grow. In the third quarter of 2023, the most recent to be reported, sales in the e-commerce business grew by 9% year over year in North America and 12% year over year internationally. And this was in a year when many were worried about consumers cutting back on spending.

Even so, it could still have a lot of growth ahead of it. The international side of the e-commerce business is the faster-growing part but makes up only about 27% of the total sales volume today. Plus, e-commerce only makes up 16% of U.S. retail sales today, according to the Census Bureau, and this percentage has been steadily rising for years.

AI has several big applications in Amazon's e-commerce business. Just to name a few, it allows the company to do a better job of personalizing product recommendations, and allows Amazon to more effectively target advertisements, as ad revenue is a major growth driver for the company right now.

AWS could be a massive winner

While it isn't quite as dominant as Amazon.com is in e-commerce, Amazon Web Services (AWS) is the market leader in cloud services.

AWS is the fastest growing part of Amazon's business, with 19% year-over-year growth in the latest quarter. And not only is AWS growing fast, but it's highly profitable. It posted a 38% operating margin in the third quarter, compared with about 6% for North American e-commerce.

The cloud computing market is expected to roughly triple by 2032 from 2024 levels, according to Fortune Business Insights. AI and machine learning are expected to be a big part of it. As one example, on the day I'm writing this, AWS just announced a partnership with venture capital firm General Catalyst to develop AI tools for the healthcare industry.

AWS offers several AI services for customers, including the Amazon Q customizable AI assistant for businesses, the Amazon Transcribe speech-to-text feature, and the AI-powered Amazon Fraud Detector, just to name a few.

The price is right

Not only is Amazon's business growing, but it is becoming more efficient -- a big focus of CEO Andy Jassy. Overall revenue grew 11% year over year in the latest quarter, but earnings per share grew by 52% and free cash flow more than doubled. The combination of growing revenue, especially on the AWS side, and management's continued focus on profitability could keep EPS growth elevated for years to come.

Amazon isn't exactly a cheap stock at about 37 times forward earnings, but with rapidly expanding profitability and a big growth opportunity ahead, I believe you get what you pay for. Amazon is one of the cheapest Magnificent Seven stocks on a P/E basis and has seen the smallest expansion of its price-to-sales ratio from five years ago.