I have about 40 linux instances running in AWS across multiple regions under VPC. Now I need to patch linux kernal, run updates for apache, php, mysql. Its quite hard to do it logging in to each servers. how to automate this process or easily run updates on all the servers at once.
For this situation you might be more or less forced to do this by hand, but in the future a design makeover would be in order to make your life easier for dealing with stuff like this. I would recommend that you look into puppet or Chef as they enable you to script your infrastructure and when you have updates/changes that need to occur, you apply them to the systems in question or just rebuild the system over again.
For this scenario if you were to use Chef, you would just update your scripts and tell chef to update all of your systems.
Granted, I know that this bit of information doesn't help your current predicament, but it's a recommendation for future environments to alleviate issues like these.