Target is struggling mightily to compete with Amazon in retail, but it's finding other ways to fight back. The discount retailer is scaling back its use of Amazon Web Services, according to sources familiar with the matter, as the company aims to take greater control over its infrastructure and stop financing its chief rival. Amazon's purchase of Whole Foods is the latest sign of how deep the e-commerce giant is moving into all forms of retail. Microsoft Azure is among the rival cloud vendors vying to nab Target's cloud business, said the sources, who asked not to be named because the plans are confidential. Google and Oracle are also beefing up their cloud offerings. Like all big box stores, Target is being trounced by Amazon, which is selling more items for cheaper and delivering them faster. Target's annual revenue is lower than it was five years ago --though the company has sold off its credit card business and pharmacy division during that stretch -- and the stock has lost 23 percent of its market value in the past 12 months. On Monday, Amazon finalized its $13.7 billion purchase of Whole Foods and instantly cut prices in stores by more than 30 percent on organic fruit and meat. From electronics and household goods to toiletries and groceries, Amazon is expanding its inventory.

While there's little Target can do to impede Amazon's dominance in retail, the emergence of other cloud providers at least allows the company to spend its computing and storage dollars elsewhere. According to one source, Target is planning to aggressively move e-commerce activities, mobile development and operations away from AWS through the end of the year and probably into 2018. A Target spokesperson said the company doesn't discuss details of its vendor relationships, but added that "we currently use multiple cloud service providers and will continue to do so." An Amazon representative declined to comment. Target hinted at its plans in October, when the company said it adopted an open-source system called Spinnaker that Netflix built to enable developer teams to customize their clouds. One key component is that "Spinnaker was built to work with multiple public clouds versus just one," Target said in a post on its website. Target isn't the only large retailer taking aim at AWS. The Wall Street Journal reported in June that Wal-Mart was telling its tech vendors not to run applications on Amazon's cloud and that for its own infrastructure the company uses a combination of on-premise servers and services provided by Microsoft and others. "If I'm running Azure or Google, I'd go right after those guys," said John Vrionis, a partner at Lightspeed Venture Partners who backs infrastructure start-ups. "I'm sure they could package a compelling migration plan and those are segments are probably most thirsty for that." Still, AWS has yet to see any mass exodus. In the second quarter, AWS controlled 34 percent of the cloud infrastructure market, topping Microsoft, IBM and Google combined, according to Synergy Research Group. Brands and stores including Brooks Brothers, Nordstrom, Nike, Under Armour and Lululemon are all AWS customers, though sources say that many retailers are considering other cloud providers.

Target isn't talking publicly about where it will host its data and apps, but the company isn't hiding its efforts to invest in software development. Since Mike McNamara, chief information and digital officer, joined in 2015, Target has hired more than 1,000 engineers and has prioritized bringing technical talent in-house, rather than outsourcing it. Of the 95 openings for technology positions on Target's website, about 80 percent were listed since the beginning of July. In the past week, jobs have opened up for senior database engineers and experts in open-source tools like Node.js and Cassandra. All of the seven positions that require experience in cloud infrastructure call for expertise in some combination of AWS, Azure, Google or other offerings. Digital commerce is one area where Target is seeing improved results. In 2013, the company introduced Cartwheel, a mobile discounts app that has become a popular way to shop and was just integrated with the core Target app. According to research advisory Gordon Haskett, the number of Cartwheel users increased 50 percent in 2016, and the firm predicted that the combination with the Target app will drive even more business. "Once complete, the consumer will be able to make their lists, find items in stores, take advantage of great offers, and pay for their orders, all from within a single app," the firm wrote in a report on May 8. Updates with comment from Target spokesperson and to say that the company sold off two businesses in the past five years. --CNBC's Eugene Kim contributed to this report.

WATCH: Big-box stock wars