An approach to Arnold's diffusion through the calculus of variations