With shares up by a whopping 78% over the last 12 months, Amazon (AMZN 0.58%) stock is finally bouncing back from the slump it experienced in 2022 -- with profitability returning to historic highs. Is this trend just a fluke or the start of a new bull run? Let's dig deeper to see what the next five years could have in store for the iconic tech giant.

A leaner and meaner Amazon

While Amazon initially benefited from a surge in demand during the COVID-19 pandemic, this led to dramatic overexpansion in its staff and fulfillment infrastructure. When consumer spending softened in 2022 and 2023, the company was left with much lower margins and profits.

The main goal of CEO Andy Jassy, who took the helm in 2021, has been to streamline Amazon through layoffs and operational efficiencies. So far, the results have been impressive. While first-quarter net sales increased by a modest 13% to $143.3 billion, operating income surged by roughly 220% to $15.3 billion to mark the company's first double-digit (10.7%) operating margin on record.

Amazon has managed to cut costs, particularly in its lumbering e-commerce business, where it streamlined its national fulfillment network by focusing on more efficient regional hubs spread across the country. It has also pivoted to higher-margin service-related businesses, such as Amazon Web Services (AWS) and digital advertising, which will play an increasingly important role for the company over the next five years.

What could the next five years have in store?

Over the next half-decade, Amazon's retail e-commerce operations will probably transition into a mature cash cow while new service-related ventures power the next leg of growth. Generative artificial intelligence (AI) might be the most promising opportunity.

Nervous investor watching his stock performance.

Image source: Getty Images.

While Amazon is cutting operational costs, it is also ramping up capital spending into cloud-based AI projects like Bedrock, a platform designed to help clients train and run their large language models within Amazon's AWS ecosystem. And it is also developing its own custom chips called Trainium and Inferentia, designed to drive cost savings on the AWS platform and reduce dependence on third-party suppliers like Nvidia.

It is still unclear how big the global AI industry will become over the next few years. However, one analyst at New Street Research believes AI-related workloads could account for 21% of Amazon's AWS revenue by 2025 and expand at a compound annual growth rate (CAGR) of 54% until 2027.

Is Amazon stock a buy?

With a forward price-to-earnings (P/E) multiple of 43, Amazon stock is not cheap compared to the Nasdaq-100 average of around 30 -- especially considering the company's large size and modest top-line growth rate. That said, Amazon's valuation looks reasonable because of its convincing framework for improving profitability over the coming years.

New opportunities in AI infrastructure could lead to disproportionate growth in the AWS segment, which generally enjoys much higher margins than Amazon's core third-party marketplace. And management's cost-cutting efforts look far from over. According to Business Insider, the company now aims to reduce its physical office footprint, which will compound the cost efficiencies gained by its earlier workforce reductions.

Amazon stock remains a strong long-term buy and looks capable of outperforming the wider market over the next five years.