The former prime minister also told an audience that he believes that the deal will be voted through Parliament, saying: "The thing about the greased piglet is that he manages to slip through other people's hands where mere mortals fail."
Mr Cameron said that if he were still in Number 10, he would have opted for a deal that guaranteed a closer relationship with the EU, and which would keep the UK within the customs union.
But he added that Mr Johnson's deal represents a better choice than no-deal and comes close to what was promised in the 2017 election manifesto.
After saying that he would vote for the deal, the ex-MP said: "The country voted to leave the European Union, the best way to leave is with a deal, I think a no-deal Brexit would be bad for the economy and bad for the union.
"I think it's much better to leave with a deal, and I think Boris has done well to achieve that deal.
"I hope he'll get it through Parliament, I suspect he will but it will be tight."
Mr Cameron, 53, was speaking at Harrogate's Crown Hotel on the first night of the town's literature festival to promote his book, For The Record.
Fielding questions from the BBC's James Landale, the former PM said of the deal: "At the end of the day, I think this is quite close to what was talked about in the 2017 manifesto, and it is a way of leaving with a deal, so I think that is the right thing to do.
"We can't go on being stuck. You can't rule out having a general election if Parliament cannot pass this deal and is still stuck, and you cannot rule out a second referendum."
Asked about his relationship with Mr Johnson and whether they had nicknames for one another, Mr Cameron said that a friend had texted him earlier on Thursday to ask if the new Brexit deal would be voted through Parliament.
Mr Cameron said he responded: "The thing about the greased piglet is that he manages to slip through other people's hands where mere mortals fail."
A small group of protesters had formed outside the hotel prior to Mr Cameron's talk, and he was repeatedly interrupted during the event.
At one stage, as he discussed the reasons for calling the 2016 referendum, one woman stood up and shouted: "I think the good people of Harrogate came here to hear an apology from you."
As other audience members responded with a mixture of angry boos and applause, a man called out: "Apologise for ruining our country."
It came after the author had described the three years following the referendum as "very painful for the country".
When Mr Cameron was at one stage discussing ways to unite the country following the division of the referendum, another man interrupted and shouted: "Your policy of austerity did absolutely nothing to bring this country together."
When the man spoke across him as he attempted to respond, the former Conservative party leader quipped: "You can pay £35 to shout at me in here, or you can shout at me outside for free afterwards."
The comment prompted cheers from the remaining members of the crowd.