Amazon (AMZN -1.14%) has proven it can reward investors over time. Shares of the retail giant gained more than 800% over the past decade -- and last year they topped $3,000. That's as the company's revenue and profit climbed into the billions of dollars. And key metrics like free cash flow and return on invested capital rose over time.

Since the beginning of the year, though, Amazon's share performance has stumbled. The stock has lost about 37%. That's as problems like rising inflation and supply chain challenges have hurt earnings. Even Amazon's recent stock split failed to offer the shares a boost. Considering all of this, what's an investor to do? Before deciding, let's look at two reasons to buy Amazon right now -- and one reason to sell.

1. The future of e-commerce

E-commerce is growing. And Amazon is well positioned to benefit. In the U.S. alone, e-commerce may reach more than $1 trillion in sales this year, according to Insider Intelligence's predictions. And Amazon represents about 40% of U.S. e-commerce sales, Insider Intelligence's data show.

Why am I so sure Amazon will continue to dominate? Because of the company's Prime subscription program. As of 2020, the company had more than 200 million members. And Amazon has been attracting "millions" of new members in recent quarters. Members pay a fee, and in return they get free same-day or one-day delivery of orders as well as many other benefits.

In Amazon's most recent earnings call, the company said Prime members have been depending more and more on Amazon for their shopping and entertainment over the past two years. It's easy to imagine that continuing as members appreciate the convenience of the service. Here are two particularly good signs: Amazon says membership renewal rates continue to be high. And members have been spending more and more.

2. Ongoing strength in AWS

Amazon isn't just about e-commerce. The company's biggest profit driver actually is Amazon Web Services (AWS). This is Amazon's cloud computing business. Last year, it represented more than 70% of the entire company's operating income. AWS is the global market leader. It's held between 32% and 33% share of the market over the past few years, according to Synergy Research Group.

And AWS isn't experiencing the same pressures as Amazon's e-commerce business these days. AWS posted double-digit growth in sales and operating income in the first quarter. Those metrics came in at $18.4 billion and $6.5 billion, respectively. That's as AWS continued to attract big customers. For example, Spanish telecom provider Telefonica is using AWS for technology such as private 5G networks.

AWS' growth is likely to continue. The company is expanding AWS' infrastructure around the globe. It's planning new local zones in 32 metro areas in 26 countries. These areas bring AWS services closer to populations and big information technology zones. And Amazon said it will increase infrastructure spending this year to support the growth it's seeing at AWS. So, AWS looks like a long-term profit driver.

Reason to sell: Inflationary pressure isn't over

Higher inflation is a problem for Amazon because it impacts the company's costs. In its earnings call, Amazon said higher inflation probably will continue longer than the company initially expected. That's as turmoil in Ukraine weighs on fuel prices. Amazon said it now costs more than twice as much to ship in international containers than it did before the pandemic.

To maintain competitive prices, Amazon doesn't aggressively pass on higher costs to shoppers. It's the right decision for long-term business because it will keep customers coming back. But this could hurt earnings in the short term.

Another problem with a higher inflation environment: Shoppers also are faced with higher prices for everything from necessities to entertainment. So, they may make fewer non-essential purchases at this time.

All of this means Amazon's earnings troubles might not be limited to a quarter or two. The struggle may go on a while longer.

What's an investor to do?

The answer depends on your individual situation. For example, if you've held Amazon shares for many years, you may want to reduce your position and lock in some of the gain. The stock's troubles may last until the economic situation improves. And that might take some time.

But for most others, I say the reasons to buy Amazon far outweigh the reason to sell. I like the long-term prospects of the e-commerce and cloud computing businesses. Amazon also is taking steps to control the costs it can control -- such as those relating to productivity. All of this means that over the long term, Amazon -- and its investors -- can win again.