Perhaps one of the more gut retching letters to write, a resignation letter, once stripped of the emotion, is very simple to write.
Keep it short and sweet. Be cordial, appreciative, grateful. Never vent frustration or anger—less is more.
Thank your manager for the opportunity, for the support and for your advancement. Make a short point about launching into ‘the next chapter in your career’ or something to that effect. Wish everyone the best.
In virtually all situations, 2 weeks notice is sufficient. The truth is, you may be very hard to replace but staying on rarely makes sense. If nothing else, there’s the damage to morale–all those folks asking why you are leaving and where you are going isn’t healthy.