Amazon (AMZN -1.64%) doubled its already-massive fulfillment center footprint in two years, and now it's paying the price.

Amazon will lay off 18,000 workers amid a slowdown in online retail growth, and many of its warehouses are sitting under-utilized. Amazon's using less than two-thirds of its total capacity, according to data from consulting firm MWPVL International. That's down from 85% in 2019.

Analysts say it could take years for Amazon to recover from overbuilding, as unused warehouses weigh on cash flow. But challenges breed innovation, and it could be a catalyst for Amazon to build new services using its excess capacity.

Amazon is making lemonade out of lemons

With so much extra capacity in its warehouses, Amazon has a lot of options for what it can do with the space.

Last summer, it started offering subleases on some of its warehouses. The move allows Amazon to recoup some of the cost of building and leasing new warehouses. Amazon's only taking this route with a small portion of its total warehouses based on size and location.

Importantly, Amazon can be exacting in where it leases warehouse space and how long it leases the space for. That gives it a lot of flexibility for the future. When e-commerce sales pick back up, it can terminate the leases and go right back into growth mode. It won't be caught flat-footed if there's another spike in demand, and it remains confident it can grow into the space.

Additionally, Amazon launched Buy with Prime last year. The service allows third-party retailers to offer Amazon Prime subscribers the ability to use their fast-shipping benefits on merchant websites outside of Amazon. On the back end, Amazon handles the entirety of the logistics, including storing inventory in its warehouses.

The service was initially restricted to merchants that already use the Fulfillment by Amazon service. Amazon is making it available to all merchants in the U.S. by the end of January.

It'll take some time for Buy with Prime to gain momentum. Amazon needs to win adoption from other e-commerce companies and then it needs to get Prime members to realize it's an option. Amazon's third-party seller services have outpaced its own retail sales for years, and this is just another path toward growing third-party sales through Amazon's logistics network.

Amazon's also building a program it calls Amazon Warehousing and Distribution, or AWD. It's calling it "supply chain as a service," and it allows companies to store inventory in Amazon's warehouses and automatically distribute it to where it needs to go in order to replenish inventories across local fulfillment centers, wholesalers, brick-and-mortar stores, or any other location. Considering the marginal expense for Amazon, which already has the warehouse space and tons of trucks and planes criss-crossing the country, it's a great high-margin use of its resources.

Amazon is still working toward fast fulfillment

Amazon hasn't quite hit the pause button on its fulfillment center build-out.

While the pace of building slowed significantly in 2022, and it'll slow further in 2023, Amazon's still selectively building new fulfillment centers and delivery facilities. Those types of facilities, as opposed to big warehouses in rural areas, are designed to get items to customers' doors faster. Amazon's expanding its ability to deliver more items within one day, sometimes the same day, with its new fulfillment centers.

The company settled on this strategy as a way to win sales from brick-and-mortar retailers where fulfillment speed can be the deciding factor. If a customer is out of coffee, they can't wait two days to get more coffee, they need it tomorrow morning.

Even while its big warehouses in suburban and rural areas remain well below capacity, there's still demand from Amazon to grow its footprint. The new fulfillment centers can provide immediate value to Prime members, but they could also play a role in maintaining fast fulfillment speeds across all regions when growth picks up again.

Should you buy Amazon stock?

A lot has been made of Amazon overbuilding its fulfillment network, and the stock was punished severely as growth slowed faster than expected. Amazon's closing some facilities and letting go of lots of workers to right-size its capacity. But at its current price, it may present a significant bargain for investors.

Shares currently trade at the lowest price-to-sales ratio Amazon has seen since 2015. While the downturn in sales is disappointing, the opportunities that lay ahead for Amazon are great. Management has the capabilities of capitalizing on its position, and the excess capacity in its warehouses could turn into the next big growth driver for Amazon's bottom line.