Factory-pressed CDs last a long time (100 years and more, depending on ambient conditions). The organic materials used in burned CDs are not as durable, IIRC.
Does vinyl last longer? Keep in mind, vinyl degrades each time you play it due to mechanical wear...