Shares of tech titan Amazon (AMZN 0.58%) just got confirmation that the 2023 rally is the real deal. Second-quarter 2023 revenue increased 11% year over year, and the bottom line swung back to black, coming in at $6.7 billion in net income. That was more than double the net profit from last quarter, and compares to a $2 billion net loss in Q2 2022.

Nevertheless, worry remains over the global economic slowdown and how it will affect some of Amazon's biggest moneymakers -- like the cloud computing segment Amazon Web Services (AWS). This FAANG stock is holding up really well, though, and still looks like a great buy for the long haul. 

Cloud, ads, and e-commerce services carry the day

For most consumers, Amazon is an online store. But it's not Amazon's own e-commerce store that's fueling most of this new spate of growth. 

Rather, Amazon is making hay as a facilitator for other people's internet businesses. Specifically, third-party seller services and ads were the catalyst for Q2 e-commerce growth, both handily outpacing the company's overall 11% year-over-year revenue expansion. And the longtime profit generator for Amazon, cloud infrastructure AWS, also continued to chug along. 

Amazon Segment

Q2 2023 Revenue

Growth (YOY)

Third-party seller services

$32.3 billion

18%

AWS

$22.1 billion

12%

Advertising services

$10.7 billion

22%

Data source: Amazon. YOY = year over year.

What exactly do these three segments do? Advertising is pretty straightforward. As Amazon's marketplace expands to encompass more third-party merchants, the company is making more money from allowing those merchants to advertise to potential buyers. As for third-party services, those are also geared toward merchants using the Amazon marketplace. Amazon makes money from facilitating services ranging from accounting and tax management to shipping and returns to seller inventory management.  

AWS' momentum has continuously slowed in the last year due to the global economy also slowing, as well as increased competition. But as CEO Andy Jassy pointed out in his annual letter earlier this year, cloud computing (accessing data and apps operated in a remote data center owned by Amazon) is still a small percentage of worldwide IT spend and has clear merits for many businesses. AWS is the leader in cloud infrastructure, and thus continues to benefit from migration to the cloud from traditional IT. 

Cash generation is only just getting restarted

Amazon has lots of irons in the fire, and after restructuring its business for optimal profitability during the bear market of 2022, this e-commerce pioneer is starting to hit its stride again.

Net income wasn't the only metric to flip from negative to positive territory. Free cash flow over the last trailing-12-month period is now $7.9 billion, versus a loss of $3.3 billion last quarter and a loss of $23.5 billion in Q2 2022 on a trailing-12-month basis.  

In other words, Amazon is profitable by all metrics again. 

I doubt Jassy and company are content, though, given the amount of money invested in e-commerce fulfillment centers and AWS data centers the last few years are still weighing heavily on free-cash-flow profit margins. I expect lots more emphasis on boosting profitable growth in the years to come. 

But the good news is that operating income (a metric before cash spent on investments into real estate development and equipment are subtracted) is up 74% on a trailing-12-month basis to $61.8 billion. It represents an operating income margin of 11.5% -- not bad, but there's certainly lots of room for improvement compared to margins from Amazon's big tech peers where 20%-plus margins are the norm.

Amazon stock now trades for 24 times trailing-12-month operating income. If you think the business will continue to drive this metric higher over the next decade from e-commerce services, ads, and cloud, it still looks like a buy now to me.