Last year was difficult for Amazon (AMZN -0.20%) as the e-commerce giant succumbed to economic problems that sent its financial results, along with its share price, moving in the wrong direction. However, 2023 has been a different story. Amazon's stock is up by 66% since the year started, partly reflecting improved financial results -- and prospects.

Let's look into the tech giant's latest quarterly results, along with the broader picture that long-term investors should be considering, to see if the stock is a buy now.

Not the Amazon of old, but things are looking up

Consumers decreased spending across the board in 2022, significantly impacting Amazon's retail operation. Businesses also reduced ad spending, so the company's ad revenue wasn't as high as it would have liked. For much of last year, Amazon's cloud business, Amazon Web Services (AWS), was doing a disproportionate amount of the heavy lifting on the top and bottom lines considering its smaller overall size compared to Amazon's other major segments.

In fact, AWS did all of the heavy lifting on the company's operating income last year as the company's other main units saw operating losses. However, even AWS slowed down last year when corporate customers decreased cloud spending. Thankfully, things seem to be improving for Amazon as the company saw revenue growth across the board in the second quarter, with AWS not needing to be the only star of the show. 

Amazon's second quarter earnings.

Amazon's second quarter earnings.

In particular, Amazon's advertising business seems to be coming back with a vengeance. That should continue as the economy rebounds, but Amazon should also see increased spending from customers and stronger retail sales, helping boost third-party seller services (shipping fees and the like), too. The company decided to absorb much of the higher costs it incurred last year due to inflation instead of passing on these expenses to its customers.

Sacrificing short-term profits to help maintain customer satisfaction and loyalty is right down Amazon's alley. After all, the company prides itself on its obsession with customer service. Overall, Amazon's net sales increase of 10.8% year over year to $134.4 billion is well below what investors are used to. But considering it reported a net loss last year, a second consecutive quarter of profits is a significant step in the right direction for the tech company

To the cloud and beyond 

One of the things the chart above highlights is how diversified Amazon's revenue base is these days. That's one of the company's strengths, but AWS remains its most exciting opportunity. Let's consider three reasons why. First, Amazon's cloud business generally records much juicier margins than the rest of its operations. So as AWS' revenue makes up an increasingly larger share of its top line, expect the company's profits to grow faster, too.

Second, the cloud industry still has a long runway for growth. That's understandable. Various cloud services help businesses decrease costs and increase efficiency, for instance, by eliminating the need to have and maintain physical data storage solutions. Companies that employ cloud solutions for their computing needs can, generally speaking, generate higher profits that often end up being passed onto customers. Everyone wins.

According to some estimates, the industry will see a compound annual growth rate of 14.1% through 2030 -- and it shouldn't stop there. As a leader in the space, Amazon is well-positioned to benefit. And third, the company continues to innovate and expand its breadth of services within AWS. It has invested in generative artificial intelligence, the new big thing on Wall Street this year. Amazon's track record of innovation and ability to generate plenty of cash makes it one of the best picks to profit from the rise of the cloud.

Of course, the company's other segments won't disappear. E-commerce arguably also has a long runway for growth. But Amazon spent a fortune building and maintaining the infrastructure necessary to give customers the perks they like, such as one-day shipping on thousands of items. That naturally squeezes Amazon's profits and margins.

AWS will likely remain Amazon's most profitable unit for a while, and investors will benefit from that as the company should continue to deliver excellent returns, just as it has in the past.