The written opinion of the Attorney General, heretofore or hereafter secured by any officer, board, local governing body or agency legally entitled to secure such opinion, shall protect such officer and the members of such board, local governing body or agency to whom it is directed or for whom the same is secured from liability to either the state, county or other municipal subdivisions of the state because of any official act or acts heretofore or hereafter performed as directed or advised in such opinion.