The armed officer who failed to enter the Florida school where a shooter killed 17 people to engage the gunman “believed he did a good job” by calling in the location of the massacre, a union official has said.

School resource officer Scot Peterson took up a position viewing the western entrance of the building that was under attack for more than 4 minutes, but "he never went in," Broward County Sheriff Scott Israel said on Thursday.

Mr Peterson was suspended without pay and placed under investigation, then chose to resign, Mr Israel said.

Jeff Bell, the president of the Broward Sheriff’s Office Deputies Association, told the New York Post that Mr Peterson was "distraught" but believed he had acted correctly.

“He believed he did a good job calling in the location, setting up the perimeter and calling in the description (of Cruz),” he said.

But Donald Trump, the US president, suggested the guard may have behaved like a "coward" as he publicly criticised his actions.

"He certainly did a poor job ... somebody was outside, they are trained, they didn't react properly under pressure or they were a coward," Mr Trump said.

When asked what Peterson should have done, Israel said the deputy should have "went in, addressed the killer, killed the killer."