Two of the world's biggest tech companies are teasing possible U.S. expansions.

More jobs. Big spending. Great headlines. But there's more to it.

On Wednesday, Apple (AAPL) pledged to create 20,000 jobs and invest $30 billion in U.S. facilities over the next five years. As part of that investment, Apple plans to build a new campus in the United States, with the location to be announced later this year.

Amazon (AMZN) followed that up on Thursday by revealing a not-so-short list of 20 cities it's considering for a second headquarters, all but one of which are in the U.S. The headquarters is expected to create 50,000 jobs for one lucky city.

The announcements highlight the rapid growth of the two companies, as well as the need to address the political and public relations liabilities they face because of that growth.

Apple and Amazon, like others in the tech industry, are contending with the risk of populist outrage from politicians on the left and the right.

For Apple, it comes down to the $250 billion question. Apple is sitting on more than a quarter trillion dollars overseas. Now, after the newly enacted tax law, Apple can bring that money back to the United States at a lower tax rate.

Much of that money is expected to go back to Apple shareholders in the form of stock buybacks and dividends. But the company faces political pressure to reinvest a meaningful amount in U.S. workers and the economy.

"It's difficult for Apple to return cash to shareholders and not face pressure to also invest in U.S. manufacturing, job creation, and higher employee wages," Neil Cybart, an Apple analyst who runs Above Avalon, told CNN Tech.

Related: Apple: We'll pay $38B in taxes and add 20,000 jobs in the U.S.

On the campaign trail, President Trump said he wanted to get Apple to "build their damn computers and things in this country." While Apple has long relied on American workers and technology, it's now trying to be even more overt about it.

Apple talked up plans on Wednesday to invest in the new campus focused on customer support. This will be in addition to campuses in Austin and Cupertino, California, each of which has thousands of employees.

Apple also plans to invest $5 billion in a manufacturing fund and $10 billion in data centers around the country. To cap off that investment, Apple CEO Tim Cook tweeted a picture of himself breaking ground on a new data center in Reno, alongside the city's mayor and the governor of Nevada.

In an investor note Thursday, analyst Ben Schachter of investment bank Macquarie described these investments as "worthwhile," but said "we do worry about how political pressures may influence spending in such a way that they may not be optimal for shareholders."

Amazon faces similar public and political pressure, though not tied to repatriation of overseas cash. Throughout the last year, Amazon has been characterized as a job killer and a possible monopoly.

Trump has repeatedly attacked Amazon (AMZN) for antitrust concerns and "getting away with murder tax-wise." As the retail apocalypse has revved up, analysts often point the finger at Amazon. One conservative news outlet went so far as to ask if a new automated Amazon grocery store spelled "the end of jobs."

Amazon first attempted to change the narrative about a year ago by announcing plans to create 100,000 U.S. jobs over an 18-month period. But it's the announcement about a second headquarters, rolled out like a corporate sweepstakes, that has truly captivated the public's attention.

Instead of criticizing Amazon for its part in upending industries and sparking layoffs, mayors, governors and members of Congress are lobbying Amazon for their respective cities.

James Cakmak, an analyst with Monness, Crespi, Hardt & Co., believes this PR blitz shows Amazon is now the "politically savviest company" in tech. Amazon, he says, has "got its pulse on Washington."

In fact, three of the 20 finalists for the new headquarters are in the D.C. area, which would ensure Amazon is never too far from the center of power.