The cosmological constant as a boundary term