Amazon (AMZN -2.56%) -- at one point the largest company in the world by market capitalization -- took quite the tumble in 2022. As of this writing, the stock is down 48% from all-time highs and has a market cap below $1 trillion.

Investors are worried about a slowdown in e-commerce and cloud computing coming out of the pandemic, and profitability struggles at the company. But I think Wall Street is currently missing the point with Amazon, creating a great buying opportunity for individual investors.

At less than $100 a share, Amazon stock is an absolute bargain for long-term investors. Here's why. 

AMZN Chart

AMZN data by YCharts.

Is e-commerce profitable? Yes, of course it is.

If you just looked at the headline numbers, you would think Amazon's e-commerce operation was still unprofitable. Combining its North American and international segments, the company's retail and services division brought in $434 billion in revenue in 2022 but posted an operating loss of $10.6 billion.

The bears look at this as proof that an online retail operation can never be profitable. If Amazon is not generating a profit with hundreds of billions in annual revenue, when will it ever happen?

But investors need to remember what line items are included in the operating expenses for the North American and international retail divisions. Essentially, everything except Amazon Web Services (AWS) is grouped in this income statement.

This obviously includes things like delivery and warehouse costs, but strangely also includes expenses from long-term projects like satellite internet, self-driving cars, and its Alexa voice technology division. The viability of these projects is unknown, but has nothing to do with how profitable Amazon's online stores are.

In 2018 and 2019, Amazon's North American division generated more than $7 billion in operating income (with a 4% margin in 2019) at a much smaller revenue base than in 2022. I see no reason that it can't at least get back to these margins over the next few years if it stops investing so much in these moon-shot divisions like self-driving cars.

Amazon also saw a one-time hit to profitability in 2022 due to overbuilding warehouse capacity during the pandemic. This led to some of its infrastructure going unused throughout the year, which is a headwind to profit margins. Over the next few years, it will be able to grow into this infrastructure footprint.

AMZN Operating Income (TTM) Chart

AMZN operating income (TTM) data by YCharts. TTM = trailing 12 months.

Profitable growth at AWS

Less muddled is the income statement at AWS. The cloud computing leader has put up steady revenue growth for over a decade and generated more than $80 billion in 2022. From that revenue, the division generated an operating profit of $22.8 billion for a margin of 28%. Last year, revenue at AWS grew 29% year over year. 

This year, Amazon is guiding for revenue growth at AWS to slow due to customers optimizing costs in this tough economy. AWS has a philosophy of working with its customers to spend more efficiently on their computing needs if possible, which leads to slower revenue growth in the interim but better customer relationships over the long term. This might make AWS' financials look worse in 2023 but will set the division up for success for the rest of this decade.

Regardless happens this year, over the long term, cloud computing growth looks to be just getting started. By 2028, industry analysts project the sector to hit $1 trillion in annual spending and grow at a 15% annual rate from now until then.

If AWS can grow along with the overall industry, it will hit $161 billion in annual revenue five years hence. At a 25% profit margin, this equates to more than $40 billion in annual earnings just from the AWS division.

Layoffs will lead to profitability

Over the last few months, Amazon announced it is laying off 27,000 corporate employees, which is a huge portion of its non-warehouse/delivery workforce. All else equal, this will lead to a margin boost once these employee expenses roll off the income statement.

Along with a right-sizing of its infrastructure footprint and continued growth at AWS, I think Amazon's profits are set to inflect higher in the back half of 2023 and into 2024. 

With so many different variables at play, it is difficult to predict exactly what Amazon will generate in profits over the next few years. But at a market cap below $1 trillion and its current share price below $100, I think the stock is a bargain if you plan to hold it for 10 years or longer.