We present a generalization of the coupled dipole method to the scattering of light by arbitrary periodic structures. This new formulation of the coupled dipole method relies on the same directspace discretization scheme that is widely used to study the scattering of light by finite objects. Therefore, all the knowledge acquired previously for finite systems can be transposed to the study of periodic structures.