The on-demand provision of computing resources as services over the internet is known as cloud computing. The distributed denial of service (DDoS) attack is a major security risk that affects cloud services. Because of the computational complexity that must be handled, detecting DDoS attacks is a very difficult operation for cloud computing. The back propagation neural network (BPNN) method is frequently employed for DDoS attack detection due to its great flexibility and straightforward construction. But it has drawbacks such as slow convergence, inconsistencies, and instability during training. In this work, the proposed optimized BPNN uses bacterial colony optimization (BCO) for optimizing the connection weights and biases to enhance the performance of BPNN. The optimized BPNN is developed to identify DDoS attacks in the cloud environment. The performance of the BCO-BPNN detection scheme is assessed using four DDoS attack datasets such as NSL-KDD, ISCXIDS2012, CIC-IDS2017, and UNSW-NB15. Its respective detection accuracy with the NSL-KDD, ISCXIDS2012, CIC-IDS2017, and UNSW-NB15 datasets is 0.9892%, 0.9883%, 0.9341%, and 0.9987%. The results of the studies demonstrate that the suggested BCO-BPNN performs better than existing BPNN variants, conventional BPNN, and support vector machine (SVM) methods.