As far as cash games go, playing for all of the money preflop when you have AA is ALWAYS a profitable move, no matter what your opponent has. Having said that, you should not just rip it all in if your opponent has shown no aggression, but raising is a minimum that you should do. Slow playing aces can lead to catastrophic outcomes.
As for playing AA in tournaments, almost all of the same rules apply, except bubble and ICM implications now start to come into play. In a cash game, if you lose with AA, you can just put more money on the table. In a tournament, if you get a bad beat against you, you are out of the tournament if you lose all of your chips. Having said all of that, you should still play aces aggressively, but if you are near the cash bubble or near an important ladder up, it might be wise to not play for all of the money unless you are effectively nutted up, or if you are short stacked and might miss the bubble if you don't double up.