After a pretty difficult 2022, the three major indexes rallied in the first half of the year -- and they've continued the march higher in these early days of the second half. At the same time, the economic outlook seems brighter too. The Federal Reserve no longer expects the U.S. to enter a recession this year. So now looks like a great moment to invest in a couple of stocks that could benefit as the general environment improves.

I particularly like "monster stocks," big players that have demonstrated earnings strength in the past and offer solid future prospects too. And two you won't want to ignore right now are Amazon (AMZN 3.43%) and Costco (COST 1.01%). Let's take a closer look at each.

1. Amazon

Amazon started the year off with a bang. The stock advanced 55% in the first half after the e-commerce giant proved it could overcome the challenges of a difficult economy. Last year, Amazon suffered as rising inflation weighed on its costs and on its customers' wallets. It even reported its first annual loss in almost a decade.

But Amazon set to work to improve its cost structure and make other efforts to turn things around. For example, it invested more in high-growth areas like infrastructure to support its cloud computing business. And the company also made moves to streamline its fulfillment operation, switching to a regionalized model from a national one.

These efforts are starting to help Amazon's earnings. In the most recent quarter, operating income rose, and the company greatly reduced its outflow of cash.

AMZN Free Cash Flow Chart

AMZN Free Cash Flow data by YCharts

It's true Amazon shares have gained quite a bit this year, and they may not keep climbing at this pace in the near term. But that doesn't worry me. Amazon has what it takes to excel over time. The company is a leader in the high-growth markets of e-commerce and cloud computing. Both are on track to expand in the double digits this decade, and Amazon's earnings and share price should benefit.

And speaking of share price, let's consider Amazon's valuation right now. Even after this year's gains, the stock still is trading lower in relation to sales than its average over the past few years. So now is a great time to get in on this monster stock.

AMZN PS Ratio Chart

AMZN PS Ratio data by YCharts

2. Costco

Like Amazon, Costco has been on the rise this year. The retail giant's shares have climbed more than 20%. Costco operates more than 850 wholesale warehouses worldwide and has managed to keep revenue rising even through difficult times.

Costco typically manages well even in tough economies because the company offers food and essentials in bulk and at rock-bottom prices. It also sells gasoline, which "continues to be quite profitable," Costco said in its most recent earnings report. These are items consumers always need.

As the economic backdrop improves, we can expect these areas to remain strong -- everyone loves a deal, right? And Costco could see higher sales in its discretionary categories as shoppers feel a bit more comfortable about spending on non-essentials.

So, this means Costco has what it takes to perform in times of economic weakness and strength. Even better, Costco actually makes most of its profit before shoppers set foot in one of its warehouses. That's because the company relies on membership fees for profit. They're high margin compared to the actual merchandise Costco sells.

And the great news here is Costco has extremely high customer retention rates. The company steadily reports membership renewals worldwide of above 90%.

You might say Costco looks expensive if you compare its valuation with that of retailers like Walmart or Target.

COST PE Ratio (Forward) Chart

COST PE Ratio (Forward) data by YCharts

But I would argue that Costco's worth the premium considering its business model, ability to keep customers coming back, and strength even during tough times. And that's why, even at today's price, I would easily snap up shares of this monster stock.