This result is a consequence of the action principle, but it can be derived also by a direct calculation, using the Bianchi identities.