Engine bay is perfectly fine...and that is what it is designed for.
The new generation BMWs that have an IBS (intelligent battery sensor) requires that the battery be charged from the engine bay posts...because if it isn't, it can create issues with the IBS interpreting a big change in the battery's voltage as a fault.
You didn't give the model number of the CTEK charger you have...but if it is like most of the ones discussed on the forums...it has a "maintainer" feature that should stop charging the battery when it reaches a certain voltage.
{I'm not an electrical guru...I know just enough to hopefully not electrocute myself...so if I misused "voltage" and should have written "current" or some other electrical term...can I have a "pass"?}