Amazon.com Inc. is selling bonds to refinance debt and buy back stock, as cheap borrowing costs prove too tempting to resist even for a company with tens of billions of dollars in cash.

The online retail giant is issuing debt that may total around $15 billion in as many as eight parts, according to people with knowledge of the matter. The longest portion, a 40-year security, may yield around 115 basis points over Treasuries, said the people, who asked not to be identified because the details are private.

Companies have been taking advantage of wide-open bond markets and spreads at three-year lows to score cheap borrowing, even if they don’t need it. With the economy rebounding from the pandemic, U.S. investment-grade firms are increasingly tempted to spend their cash cushions on acquisitions and dividend hikes, or borrow even more.

Amazon is coming off of a record earnings quarter and it provided a sales forecast for the current period that was stronger than analysts’ estimates. Cash, cash equivalents and marketable securities stood at $73 billion at the end of March, near an all-time high.

“They can grow into this leverage,” Matt Brill, head of North America investment grade at Invesco Ltd., said on Bloomberg TV Monday. “If you’re able to borrow for reasonably cheap, and then you’re able to get the operating leverage to go with it, it results in a lot of earnings.”

A representative for Amazon did not immediately respond to requests for comment.

Amazon has been a fairly infrequent issuer, but it comes in big on those rare occasions. It last tapped the bond market in June 2020, borrowing $10 billion for general corporate purposes. Prior to that, it sold $16 billion of bonds in 2017 to help finance its acquisition of Whole Foods Market Inc.

The proceeds of Monday’s offering will be for general corporate purposes, which may also include acquisitions and working capital. The two-year bond will be allocated for eligible green or social projects, which may include clean transportation, renewable energy and sustainable buildings, according to bond documents.

Moody’s Investors Service upgraded Amazon one notch to A1, its fifth-highest investment-grade rating, with a stable outlook. While the new debt sale temporarily increases leverage, proceeds are expected to be deployed over time for capital expenditures that fuel growth, which is a long-term positive for credit, said Moody’s analyst Charles O’Shea.

Amazon has been on a spending spree since the pandemic began, building new warehouses and cloud-computing data centers across the world to meet surging demand from online shoppers and businesses turning to remote work. Purchases of property and equipment totaled $45 billion in the 12 months ended in March, up from $20 billion during the prior period.

The company’s board of directors authorized $5 billion in share buybacks in 2016, but it has never made purchases under that authority.

Citigroup Inc., JPMorgan Chase & Co., Morgan Stanley and Wells Fargo & Co. are managing the sale.

With assistance from Alex Wittenberg and Caleb Mutua.

This article was provided by Bloomberg News.