The last few months have been delightful for shareholders of Amazon (AMZN 0.72%). The stock is up 45% in the last six months and 22% year to date.

With a market cap of $1.93 trillion, shares recently surpassed all-time highs set in 2021 as investors become increasingly optimistic about profitability in its e-commerce operations and resurgent growth in cloud computing due to the recent boom in artificial intelligence (AI).

Amazon stock is now up 100% in the last five years. But what do the next five years look like? Can it repeat this stellar performance and double yet again? Let's take a look.

E-commerce profit inflection, more growth ahead

Even though the online store is now closing in on 30 years of operations, Amazon's e-commerce and global retail operations are still growing quickly. North American sales increased 12% in 2023 to $353 billion, with international operations growing 11% to $131.2 billion.

Even though Amazon's platform is so dominant within the e-commerce sector, online shopping makes up only an estimated 15.6% of retail sales in the United States today. If that number can consistently rise over the next 10 to 20 years and Amazon can maintain its market share, there are still many years left to increase sales.

The best part about this growth at Amazon's e-commerce division is where it is coming from. Third-party seller services were up by 19% year over year last quarter, and advertising services increased 26%. These high-margin segments can drive overall profit margins higher if they keep growing quickly.

And that is exactly what we are seeing today. North American operating margins hit 6.1% in the fourth quarter of 2023, expanding for each of the last six quarters and reversing from negative 0.3% in the fourth quarter of 2022. In 2024, investors should expect e-commerce profit margins to continue climbing higher.

A cloud computing rebound

The most profitable segment at the company is its cloud computing division, Amazon Web Services (AWS). In 2023, it generated over $90 billion in sales and $24.6 billion in operating income, giving it a profit margin of 27.1%.

However, back in late 2022 and early 2023, there were major concerns about a slowdown at AWS. Revenue growth fell from 28% in the 2022 third quarter to 12% in the 2023 second quarter as the company helped its software customers save on costs after the height of the pandemic.

Today, these concerns have proved to be too pessimistic. AWS revenue accelerated in the fourth quarter to 13% growth, which has sent the stock higher. And 2024 and 2025 revenue looks promising with the rapid rise in AI services. These new products use a ton of cloud computing to operate, and AWS is looking to be one of the leaders in this space along with Alphabet's Google Cloud and Microsoft Azure. For example, the company has signed an extensive agreement in the space with fast-growing start-up Anthropic.

Over the next decade and beyond, analysts expect cloud computing to continue its ascent, increasing at a double-digit annual rate. If Amazon can maintain its market share lead as it has in e-commerce, AWS should have many years of growth left ahead.

AMZN Chart

AMZN data by YCharts.

Where will Amazon stock be in five years?

To estimate where the stock will be five years from now, we need to make some profit estimates for both e-commerce and AWS. Let's assume that e-commerce -- excluding the unprofitable international segment -- can grow sales by 12% annually over the next five years and expand profit margins to 10%. That would put 2028 North American retail profits at $62 billion.

Doing the same for AWS, let's assume five years of 12% growth and profit margins that remain at 27%. In 2028, that would equate to $43 billion in AWS profits. Add both numbers together and you get $105 billion in earnings from Amazon in 2028, and that excludes any upside from other divisions such as international e-commerce or satellite internet services.

Now comes the hardest part: What earnings multiple will Amazon trade at in 2028? An exact answer is impossible, but with a wide competitive advantage in both cloud computing and e-commerce, I think the stock deserves to trade at an above-market multiple of 30 times earnings, otherwise known as a price-to-earnings ratio (P/E).

Multiply $105 billion by 30 and you get a market cap of $3.15 trillion, or a 66% boost from today's price. While not a doubling, it looks like Amazon still has upside for shareholders who remain for the long haul.