Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Well here is a counter example to your argument that M is principal. Take M=A^2. And a surjective morphism defined by (1,0)->1. (0,1)->0. Then M is not principal although there is a surjective morphism.