The S&P 500 has plunged into a bear market this year, falling on the fear that high inflation and rising interest rates could spark a recession. That market crash has erased trillions of dollars in wealth and left many investors disheartened. But there is a silver lining to the downturn: Every past bear market has ended in a new bull market, meaning the next bull market is almost certainly on its way, and bear markets have historically been an excellent time to invest.

With that in mind, Warren Buffett owns 47 stocks and two index funds through Berkshire Hathaway's equity investment portfolio. Those securities are collectively worth about $306 billion, and $164 billion of that total comes from unrealized capital gains. In other words, Buffett has made a killing in the stock market, and he has done so consistently, which makes him an excellent role model.

Here are my two top Buffett investments to buy before 2023.

1. Amazon

E-commerce and cloud computing giant Amazon (AMZN -0.07%) represents less than 1% of Buffett's invested assets, but he hasn't sold a single share since first buying the stock in 2019. In fact, he called himself an "idiot" for not buying sooner. To that end, I wouldn't be surprised if Buffett added a few more shares of Amazon to his portfolio during the current quarter. The Oracle of Omaha loves to buy solid businesses when they are in distress, and Amazon is certainly in distress this year.

The company reported a loss in the first and second quarters, marking its first quarterly losses since 2015. But that says more about the macroeconomic environment than it does about Amazon. Consumers have pulled back on discretionary purchases in response to high inflation, putting downward pressure on revenue.

Meanwhile, continued investments in fulfillment capacity, coupled with the rising cost of fuel and utilities, have pushed operating expenses higher. Fortunately, the macroeconomic challenges are temporary, and Amazon is well positioned to return to profitability. In fact, the company should be more profitable than ever in a few years.

The investment thesis is straightforward: The Amazon brand is synonymous with online shopping, and the company operates the world's most popular online marketplace, receiving about twice as many monthly visitors as the next-closest retailer. That means Amazon should be integral to e-commerce for the foreseeable future, and global e-commerce sales are expected to grow at nearly 14% annually to reach $15 trillion by 2030, according to Ameco Research.

Better yet, its marketplace's popularity has allowed Amazon to build a booming digital advertising business. It is the world's fourth-largest advertiser -- and rapidly gaining ground on industry leaders Alphabet's Google and Meta Platforms. That puts the company in a good spot to create value for shareholders for two reasons. First, digital advertising comes with much higher margins than retail. Second, global digital ad spend is expected to grow at 9% annually to approach $1.3 trillion by 2030, according to Precedence Research.

Finally, Amazon Web Services (AWS) is a cloud computing powerhouse. In October, IT research specialist Gartner named AWS the industry leader for the 12th consecutive year, noting that it commands twice as much market share as the runner-up, Microsoft Azure.

Again, that positions the company to create value for shareholders. AWS regularly reports operating margins at around 30%, much higher than retail's low-single-digit operating margins. And the cloud computing market is expected to grow at nearly 16% annually to approach $1.6 trillion by 2030, according to Grand View Research.

In a nutshell, Amazon has a great shot at delivering double-digit revenue growth through the end of the decade at the very least. Better yet, its bottom line should grow even faster than its top line as digital advertising and cloud computing become bigger parts of total revenue. On that note, shares currently trade at 1.8 times sales -- its cheapest valuation in five years. That creates an excellent buying opportunity for long-term investors.

An investor sits at his desk, reviewing financial documents on paper and his laptop.

Image source: Getty Images.

2. Vanguard S&P 500 ETF

Like Amazon, the Vanguard S&P 500 ETF (VOO -0.10%) represents less than 1% of Buffett's invested assets, but he has frequently said a low-cost S&P 500 is the most sensible option for the great majority of investors.

The Vanguard S&P 500 ETF tracks the returns of the S&P 500, an index comprising 500 of the largest U.S. companies. It provides exposure to growth stocks and value stocks, and since its constituents span all 11 stock market sectors, it offers instant diversification.

Better yet, investors can sleep easy at night knowing the S&P 500 has recovered from every bear market and produced a positive return over every rolling 20-year period since 1919. In other words, if you had bought and held an S&P 500 index fund for at least 20 years at any point in the past century, you would have made money.

There is no such thing as a "sure thing" when it comes to the stock market. However, with a long enough holding period, an S&P 500 index fund like the Vanguard S&P 500 ETF is a relatively safe way to gain exposure to the stock market.