Uncle Sam awarded more than $500 billion in outsourcing contracts in the most recent fiscal year, paying for everything from submarines to janitorial contracts.

The spending flowing to outside businesses accounts for roughly one out of every three dollars of discretionary government spending, which is everything except for entitlement programs such as Social Security or interest on U.S. debt.

The spending figure comes from the federal Office of Management and Budget's website USASpending.gov.

Government outsourcing drew attention Monday after Edward Snowden, who recently worked for consulting firm Booz Allen Hamilton (BAH), revealed himself to be the source of a leak about a National Security Agency program to collect data on Verizon (VZ) phone customers.

The revelation brought light to the fact that 99% of the $5.8 billion in annual revenue at Booz Allen comes from contracts with various departments of the federal government, making it the 14th-largest government contractor.

Related: Booz Allen Hamilton in spotlight over leak

The $517 billion figure doesn't even include many contracts awarded by the NSA and other intelligence agencies, since much of government spending in those departments is classified. For example, the figures show only $4 billion going to Booz Allen, even though the company's own financial filing reveals that virtually all of its $5.8 billion in revenue comes from government contracts.

Related: What the NSA costs taxpayers

Booz Allen focuses on cybersecurity and technical support for government computers and networks. Besides defense and intelligence agencies, it works for such civilian agencies as the Department of Health and Human Services and the Internal Revenue Service to make sure their computer systems and networks are both secure and efficient.

The $517 billion spent is actually the lowest since the fiscal year that ended in September 2007. The record high was $540.8 billion in contracts in fiscal year 2008. Spending on outside contracts stayed near that level for the following three years before the most recent decline. But even the current figure is nearly twice the spending on contracts in fiscal year 2002.

"You have a continual ebb and flow. You have continued debate whether work should be done within the federal government or contracted out," said Nick Palatiello, media relations director for the Business Coalition for Fair Competition, a trade group for contractors.

Government contractors brace for spending cuts

Nick Schwellenbach, senior fiscal policy analyst Center for Effective Government, said that most of the increase in contracting in the last decade was due to the ramp-up in defense and intelligence spending after the Sept. 11 terrorist attacks, and for support services that those agencies needed.

He said the recent pullback in spending is due primarily to the withdrawal of U.S. military forces from Iraq, as well as a slight shift back to in-house government work and greater use of fixed-cost contracts under the Obama administration.