Chilling surveillance video released Thursday of the deadly attack at a Florida high school shows the actions of a disgraced security resource officer who stayed outside as 17 people were slaughtered inside.

The footage shows Scot Peterson taking up positions at Marjory Stoneman Douglas High School in Parkland, at times running and talking on his radio.

Peterson can be seen with an unidentified school worker walking toward a room at 2:22 p.m. — less than a minute after the first shots were fired, allegedly by Nikolas Cruz, 19.

Less than a minute later, three people — Peterson and two others — are seen on a golf cart driving through campus.

Students, who had their images blurred in the footage, are seen running from their classrooms down an exterior hallway before being instructed to head in a different direction.

Peterson and another deputy also are seen huddled behind a building.

The Broward County Sheriff’s Office released the video after a judge sided with news outlets that sued for the right to show how the massacre unfolded at the school.

Peterson, who was armed and assigned to the school, did not enter the building during the shooting. Broward County Sheriff Scott Israel has said Peterson resigned after being suspended without pay.

Video of what happened inside the school during the Feb. 14 attack is not being released.

Peterson’s lawyer has said the former deputy “is confident that his actions on that day were appropriate under the circumstances” and that video and eyewitness testimony “will exonerate him of any sub-par performance.”

Through his lawyer, the veteran campus cop said he believed the gunfire was coming from outside Building 12. But police radio dispatches suggest he knew the shooting was happening inside — and he even told fellow cops to stay away.

“The video speaks for itself. His actions were enough to warrant an internal affairs investigation, as requested by Sheriff Scott Israel on Feb. 21. After being suspended without pay, Peterson chose to resign and immediately retired rather than face possible termination,” the sheriff’s office said Thursday, according to BuzzFeed.

“In accordance with Florida law, we are prohibited from discussing any other details of the IA investigation until the case has concluded.”

Cruz was arraigned Wednesday on 17 counts of first-degree murder and 17 counts of attempted first-degree murder, a week after a grand jury indicted him in the case.

Judge Elizabeth Scherer entered a not guilty plea on Cruz’s behalf.

Prosecutors said they plan on seeking the death penalty, while Cruz’s attorneys have said he would plead guilty if the death penalty was not an option.

The release of the surveillance video comes one day after students across the country staged school walkouts to remember those killed and continue the push for gun law reform.

Meanwhile, more details of the shooting emerged as Coral Springs police released recordings of 911 calls and police radio traffic.

In the recordings, students and dispatchers were uncertain about the shooter’s location. Some were terrified the gunman would find them when asked if they could perform CPR on the wounded.

“Please! Please! Please! There are people here! They are bleeding! They are all going to die!” a frantic teenage girl said from Classroom 1215, CBS News reported..

“There’s a lot of people around us that are injured, people that are injured, people that are bleeding. He is upstairs now,” she added.

A teacher from Room 1216 told the 911 operator that a student had been hit in the chest and wasn’t breathing.

“He’s twitching. There’s blood all over,” she said.

The police radio recordings showed that Coral Springs cops were the first to enter the school building after confirming that Broward County deputies had not gone in.

Officers described seeing shell casings scattered on the floor and bullet holes in the windows — and warned that the gunman might have changed clothes after they reported finding a camouflage jacket, ski mask and backpack on the first floor.

On the third floor, the cops said they found an AR-15 assault rifle with a magazine still attached. They said they shattered windows in some locked classrooms because terrified students would not open doors.

The officers found bodies and scrambled to evacuate the wounded before allowing other students and teachers to leave.

Cruz was nabbed a few blocks away from the school.