Like other retailers, Amazon (AMZN 3.43%) is facing inflation and the difficulties of labor market shortages these days. In fact, that's what weighed on earnings in the most recent quarter. Sales growth also paled by comparison to the percentage gains we got used to seeing during the worst of the coronavirus crisis.

But this gray cloud has a silver lining. Actually, it may have a few silver linings. And they come in the form of Amazon's big moneymaker Amazon Web Services (AWS), advertising revenue, and overall future prospects. These points are exactly why buying Amazon shares right now may be the smartest thing you ever do. Let's take a closer look at why Amazon is set to deliver share performance over the long term.

A group of smiling investors gather around a laptop at a desk.

Image source: Getty Images.

AWS is driving profit

Even though the retail business didn't report huge gains in the most recent quarter, AWS did. Amazon's cloud computing services business posted 40% sales growth to $17.8 billion. But this isn't a new phenomenon. AWS has driven profit at Amazon for quite some time. For example, in 2020, AWS made up 60% of Amazon's operating income. Last year, this figure climbed to a whopping 74%.

AWS is as much of a giant in its industry as Amazon is in online retail. Gartner in 2021 named AWS as industry leader in its quadrant measure of cloud infrastructure and platform services -- for the 11th consecutive year. And recent deals indicate AWS' leadership is far from over. Meta, Facebook's parent company, recently named AWS as its official long-term partner to handle artificial intelligence research and development. Best Buy chose AWS as its preferred provider. And pharmaceutical giant Pfizer has signed on with AWS to improve the drug development and manufacturing process.

Advertising revenue also is a profit driver to watch at Amazon. The most recent quarter marked the first time Amazon broke down these figures in its report. Amazon reported $9.7 billion in advertising revenue. That's a 32% increase from the year-earlier period. Amazon sells advertising to businesses, authors, and other sellers on the platform. It's clear this segment is likely to continue growing as vendors try to stand out from rivals and sell more on Amazon.

Investments in the business

And, finally, one other element makes me optimistic about Amazon's future prospects. And that's its investments in its business. Of course, this is costly in the near term. But it should pay off for the company and investors over the long term. Amazon predicts an increase in capital expenditures (capex) this year. About 40% of Amazon's capex has been in infrastructure -- and much of this has been for AWS. That's worthwhile as we see the value of this business. A good share of Amazon's spending has also gone toward fulfillment and beefing up its subscription program, Amazon Prime.

These areas are important for future growth. Chief financial officer Brian Olsavsky said Prime "welcomed millions" of new members during the fourth quarter. He also said Amazon has seen high membership renewal rates. At the same time, Amazon is increasing the price of Prime membership in the U.S. to $139 annually from $119. This will help the company compensate for some of its rising costs.

Amazon shares have slipped a bit this year. They're down about 4% so far. And last year they only gained 2.3%. But this doesn't worry me. In fact, I see this is as a great buying opportunity. Amazon has what it takes to generate enormous revenue and profit over time. This should lead to share growth. And that's why it's a good idea to get in on this unstoppable company now.