Politics always are important in this type of deals, but Russia never designed the Su-27 to be exported, it was exported because in the 1990s they needed to survive.
The initial deal was China to buy Su-27SK with Russian components.
They bought a 24 Su-27SK batch for $1 billion dollars value in 1992, pretty cheap, later they signed a deal for $2.6 billion dollars for the license of Su-27SK and China broke the deal.
China and Russia are not allies, they have historical issues such as the ownership of the Russian far east, the Chinese immigration to Russia and Chinese investment in Siberia, pretty much Russia fears China will get Siberia without a shot, just by economic means.
Russia however is engaged in stopping NATO in its western part.
Russia is sandwiched by two military threats, but has chosen the path helping China for two reasons, China while a powerful country lacks the ability to control the world, and militarily is much weaker than NATO.So when they sold Su-27s in 1990 the threat was smaller in 2017, the threat is higher, so they said no to license the Su-35.
But from the point of view of politics, China is not an ally of Russia, simply because one has ambitions over Siberia, and the other never will play second flute to China.