Diarra, 31, has 44 caps for France and has previously had a spell in England with Liverpool between 2002-2005, although he failed to make an appearance for the Reds.
Diarra said: "I am very happy to be here at West Ham - everything is signed now which is good and I am excited to be here at this club and to be playing for them in the Premier League.
"I know a lot about West Ham as a club and when I knew they were interested in signing me, I was very happy and knew it would be a good choice for me.
"We are a Premier League club and I know of players who were here before like Paolo Di Canio and Scott Parker.
"But of the players now in the team, I know Guy Demel, Mo Diame and of course, Modibo Maiga, who played in the French league last year.
"The club has just been promoted and I am looking forward to a good challenge with the team ahead. I see this as my chance in the Premier League to do well with West Ham.
"I hope that my experience can help and the fans will see me give my all in the matches."