When I was building my ebike, I used 6mm polycarbonate panel i cut into a strip and bent:
View attachment 388189
Nowadays, I would probably build a fiberglass box instead, but nevertheless this construction is still operational. I enclosed the battery pack itself in another layer of 2mm PC to allow removal for charging away from the bike:
View attachment 388190
The main box is held with 4 bolts going into water bottle mounts, as well as a pipe bracket around a top pipe. It's way more secure than any bag, imo.