Inflation hikes over the last year have been tough on Amazon (AMZN -2.88%), triggering a consumer pullback on its e-commerce site and causing businesses to slash cloud budgets. The challenges have led to significant operating losses and skepticism from investors. However, easing inflation and a leading market share in two high-growth markets suggest the company won't be down forever, making its stock a compelling long-term buy.

The company's most recent quarter revealed improvements in its North American and international segments after a year plagued by declines. Meanwhile, a planned expansion of its cloud platform, Amazon Web Services (AWS), could see it flourish alongside the booming artificial intelligence market (AI). Here's why Amazon stock is a no-brainer buy right now.

A cloud business on the rise 

Amazon Web Services proved a crucial asset amid an economic downturn last year. The platform's $22.8 billion in operating income made up 100% of Amazon's profits in fiscal 2022 after steep declines in its e-commerce segments. So when AWS showed signs of slowing growth in the first quarter of 2023, investors grew concerned. The cloud platform's revenue rose 16% in Q1 2023, a stark decline from the 37% growth it reported in Q1 2022.

However, there are still plenty of reasons to rally over AWS. On May 18, Amazon announced plans to invest $12.7 billion into its cloud business in India by 2030 as it works to scale up infrastructure in the key market. India is the world's second-largest internet market and looks likely to surpass China in the not-too-distant future. Cloud adoption in the South Asian country has soared in recent years, with Amazon's leading market share in the sector likely to strengthen through the expansion.

Moreover, advances in AI are projected to boost cloud platforms as companies increasingly integrate the technology into their services. The AI market is reportedly expanding at a compound annual growth rate of 37%, according to data from Grand View Research. As a result, Amazon's increased investment in its cloud platform could massively pay off over the long term. 

Don't count e-commerce out yet 

Last year, Amazon's e-commerce segments reported a combined $10.6 billion in operating losses as macroeconomic headwinds proved detrimental to the online business. The situation made some investors wary of the company's profitability prospects, as its e-commerce segments generated over 80% of its total revenue last year. 

However, easing inflation is gradually helping Amazon's online retail business recover, with its North American segment reporting $898 million in operating income in Q1 2023 as it returned to profitability. Meanwhile, the company's international segment also saw a marginal improvement. 

Moreover, the e-commerce market is projected to hit $4 trillion this year and expand to $6 trillion by 2027. The growth aligns with the fact that online sales only made up about 15% of all retail purchases in 2022, suggesting the sector still has a lot of room for growth in the coming years. As a result, Amazon's dominance in e-commerce through its website and Prime membership makes it well positioned to profit significantly from the industry's development. 

Reopenings after the emergency phase of COVID-19 pandemic drove millions of consumers back to brick-and-mortar stores, with subsequent economic declines compounding Amazon's losses. However, as inflation improves and the return to shopping offline wears off, the company's business could flourish. 

Amazon's growth potential is backed by multiple analysts, who have an average 12-month price target at $138. The figure projects stock growth of 18%, which aligns with the company's prospects as it works to recover from last year's losses. As a result, Amazon's stock makes an attractive long-term investment for those who believe in the future of cloud computing and e-commerce.