  The aim of this paper is to provide a rigorous mathematical analysis of an
optimal control problem of a SIR epidemic on an infinite horizon. A state
constraint related to intensive care units (ICU) capacity is imposed and the
objective functional linearly depends on the state and the control. After
preliminary asymptotic and viability analyses, a $\Gamma$-convergence argument
is developed to reduce the problem to a finite horizon allowing to use a state
constrained version of Pontryagin's theorem to characterize the structure of
the optimal controls. Illustrating examples and numeric simulations are given
according to the available data on Covid-19 epidemic in Italy.
