Spain spent the last six years investing heavily in wind and solar energy, leading to some of the cheapest power prices in Europe.