With Amazon.com Inc. (AMZN) flirting with a $500 billion valuation and shares of bricks-and-mortar rivals frequently tumbling on fears of what the company might do to them in the future, Jeff Bezos & Co. must be well-aware that Wall Street is providing them with more leeway than ever to sacrifice near-term profits to make big investments meant to drive long-term e-commerce and public cloud growth. Amazon's Q2 results and Q3 guidance show that it's making the most of this goodwill, even if doing so risks triggering a bit of selling from investors holding giant paper profits.

Amazon reported Q2 revenue of $37.96 billion (up 25% annually, better than Q1's 23%) and GAAP EPS of $0.40 (down from $1.78 a year ago). Revenue beat a $37.2 billion analyst consensus, but EPS missed a $1.41 consensus.

Q3 guidance fits a similar pattern. Revenue guidance of $39.25 billion to $41.75 billion (20% to 28% growth) is favorable to a $40 billion consensus at a $40.5 billion midpoint. But Amazon is also forecasting operating income will fall to a range of negative $400 million to positive $300 million, from a level of $575 million a year ago.

Shares fell 2.7% in early afternoon trading on Friday to $1,018.11. They're still up 35% on the year, and 10% from where Amazon traded before posting a Q1 beat in late April. For now, Bill Gates has reclaimed the title of the world's richest man from Bezos.

Amazon's U.S. e-commerce operations remain a force of nature, rapidly taking share as Amazon's third-party seller base keeps expanding, its fulfillment center expansion keeps cutting shipping times and (more importantly) more consumers get hooked on Prime.

North American segment revenue grew 27% annually to $22.4 billion, outpacing Q1's 24% growth and Q4's 22%. For comparison, comScore estimates the U.S. e-commerce market is growing 15% overall, and eBay Inc. (EBAY) , which Amazon has long been taking share from, reported its U.S. gross merchandise volume (GMV) grew just 3% in Q2 to $8.8 billion.

Watch More with TheStreet:

Jeff Bezos.
Jeff Bezos.

International segment revenue grew 17% to $11.5 billion (19% excluding forex swings), slightly better than Q1's 16% growth. This segment's sales still depend heavily on the U.K., Germany and Japan, although Amazon has been investing heavily to grow its footprint in places such as India, Mexico and France.

Amazon Web Services (AWS) grew revenue 42% to $4.1 billion, nearly on par with Q1's 43% growth. Although this is slower than the 97% growth that Microsoft Corp.'s   (MSFT)  Azure platform posted, and from all signs slower than the growth Alphabet Inc.'s (GOOGL)  Google Cloud Platform (GCP) is seeing, it's still pretty impressive for a business now on a $16 billion revenue run rate. It suggests enterprise AWS adoption continues at a healthy clip. It's worth remembering that just about every industry research report indicates that, revenue-wise, AWS remains in a league of its own among public cloud platforms.

Jim Cramer and the AAP team hold a position in Alphabet for their Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells GOOGL? Learn more now.

AWS' growth helped Amazon gross margin rise 130 basis points to 38.2%. Prime subscription growth also helped, as did a continuing e-commerce mix shift towards third-party sales, which Amazon monetizes via high-margin revenue streams such as commissions, fulfillment services and ads. Retail third-party seller services revenue grew 38% to $6.99 billion, retail subscription services revenue grew 51% to $2.17 billion and "Other" revenue, which covers ads and to a lesser extent Amazon-branded credit cards, grew 51% to $945 million.

Nonetheless, profit margins fell for all three of Amazon's main reporting segments. North American segment operating income fell 38% to $436 million, the international segment's operating loss jumped to $724 million from $135 million (India and Prime Video expansion played roles) and AWS operating income grew 28% to $916 million, less than revenue growth of 42%.

A look at Amazon's spending figures shows how a variety of investments are depressing segment profits. Fulfillment spending, lifted by warehouse openings, grew 33% to $5.2 billion. Marketing spend, driven by AWS and ad sales investments, grew 44% to $1.6 billion. And tech and content spend, driven by R&D, AWS infrastructure and Prime Video investments, grew 43% to $3.9 billion.

Warehouse and logistics investments helped Amazon's capital spending rise 46% to $2.5 billion. And AWS had much to do with a 92% increase in property and equipment acquired under capital leases to $2.7 billion. All this spending led Amazon's trailing 12-month free cash flow (FCF) minus lease repayments and assets acquired under leases to drop to $1.5 billion from $3.3 billion at the end of March.

On the earnings call, CFO Brian Olsavsky noted Amazon's Q3 profit guidance, which implies further spending increases, accounts for a slew of new warehouse openings, as well as planned second-half increases in video spend (JPMorgan previously forecast Amazon would spend $4.5 billion on video this year). He also pointed out that Amazon's warehouse growth is being driven in large part by a near-40% increase in paid unit shipments (both Amazon's and those of third parties).

Olsavsky was fairly tight-lipped about Amazon's pending $13.4 billion deal to buy Whole Foods Market Inc. (WFM) -- in general, Amazon has been much more secretive than companies usually are about their plans for 11-figure acquisitions -- and more broadly about his company's physical retail ambitions. But he did hint that Amazon is willing to step up its bricks-and-mortar investments depending on how early tests for things like Amazon bookstores and automated Amazon Go convenience stores fare.

"[W]e are experimenting with different formats, and we look at different sizes and we look at revenue cost per square foot just like any other physical retailer," he said about Amazon's bookstore efforts. Olsavsky also said Amazon thinks there will be "no one solution" for online food/grocery-ordering, and that the company is experimenting with a number of formats covering local pickup and home delivery.

If Amazon does choose to further pressure its near-term cash flow by making large physical retail investments, chances are that markets won't react too harshly, and (judging by the reaction to the Whole Foods deal) may even cheer the effort depending on the specifics. The company's performance over the past few years has at least earned management that much.

TheStreet's Eric Jhonsa previously covered Amazon's earnings through a live blog.

More of What's Trending on TheStreet:

More from Stocks

Get a Juicy 8%+ Dividend Yield With Solid Income Streams All in One Stock

Get a Juicy 8%+ Dividend Yield With Solid Income Streams All in One Stock

U.S.-Chinese Trade War Could Mash Up Apple

U.S.-Chinese Trade War Could Mash Up Apple

How to Overcome the Fear of Trading Super-Momentum Stocks

How to Overcome the Fear of Trading Super-Momentum Stocks

Tesla's People Problem and the Inscrutable Musk: 2 Things That Make You Go Hmmm

Tesla's People Problem and the Inscrutable Musk: 2 Things That Make You Go Hmmm

Dow Hits Another Closing High to End Record Setting Week

Dow Hits Another Closing High to End Record Setting Week