Amazon said it is buying MGM for US$8.45 billion, giving it a huge library of films and TV shows and ramping up competition with streaming rivals led by Netflix and Disney.