The Minimum Connecting Time for terminal 2 is 30 minutes. And that is even more than you really need, especially if you don't need to get through passport control. The terminal is designed for fast transfer time. Basically you deplane into the terminal, walk to your gate (maybe 10 minutes from end-to-end) and board again. You won't need to get through any security checks, passport control or similar.
Your only problem would be a delay on the inbound flight, but even a 20 minute delay should be fine (in most cases even checked baggage makes it in 20 minutes!). In case of a larger delay, Lufthanse often provides transportation directly from plane to plane, bypassing the terminal completely (if you would need to get through security or passport checks they even have dedicated checks on-ramp).