The 55-year-old will replace Anil Kumble, who resigned following India's Champions Trophy campaign in which they lost to in the final to Pakistan.
Kumble said he stepped down after one year because his "partnership" with captain Virat Kohli was "untenable".
India's cricket board, the BCCI, said Shastri brings "a wealth of experience, both as player and as coach".
Shastri was India's team director before Kumble's appointment as coach last year.
Zaheer Khan has been appointed bowling consultant and Rahul Dravid will be India's overseas batting consultant for the Test team.