Membership in a defense alliance is viewed as an insurance option for a country subject to military threat. The focus is on the trade-off between domestically and internationally provided security as tax-financed public goods under heterogeneous risk classes of the members. A sufficient condition for a low-risk potential member to abstain from participation and a necessary condition for the participation of a high-risk potential member are stated. Disincentives for membership can include the cost of commitment in terms of the required production of the collective good, preemptive maneuvers, and ex post punishments of the enemy. The optimal tax is shown to be declining in the safety classification of a member subject to an adverse incentive effect of free riding. Solutions for the alliance size and the cost of membership are derived in the alliance equilibrium resorting to the fixed-point solution. With costly termination of membership, multiple equilibria can arise.