Kevin Rudd, Australia's former prime minister, has resigned as the country's ambassador to the United States.