We analyse optimal investment in one of the most important forms of climate adaptation: flood protection. Investments to build dykes and surge barriers involve considerable adjustment costs, so that their construction locks in the level of flood protection for some time. Investment decisions must account for both economic and flood risk, where the latter combines flood damage and sea level rise uncertainty driven by global warming over several decades. We put forward a tractable macro-finance (DSGE) model that includes flood risk. We obtain solutions for optimal flood protection as a function of these uncertainties, costs, and preferences. Economic uncertainty leads to less (more) protection if the elasticity of substitution is greater (less) than one. Sea level rise and flood damage uncertainty always lead to more flood protection, although the first effect is small, only becoming significant after several decades. We illustrate our results with case study for the Netherlands.