The five-time world champions Brazil will take on the current world champions Spain in the Confederations Cup final.