The paper illustrates how we built a federated cloud computing platform dedicated to the Italian research community. Building a cloud platform is a daunting task, that requires coordinating the deployment of many services, interrelated and dependent on each other. Provisioning, servicing and maintaining the platform must be automated. For our deployment, we chose a declarative modeling tool, that allows describing the parts that compose the system and their relations of supplier/consumer of specific interfaces. The tool arranges the steps to bring the deployment to convergence by transforming the state of the system until it reaches a configuration that satisfies all constraints. We chose a declarative service modeling approach for orchestrating both the deployment of the platform by the administrators and the deployment of applications by users. The cloud platform has been designed so that it can be managed by this kind of automation, facilitating the deployment of federated regions by anyone wishing to join and to contribute resources to the federation. Federated resources are integrated into a single cloud platform available to any user of the federation. The federation can also seamlessly include public clouds. We describe the architectural choices, how we adapted the OpenStack basic facilities to the needs of a federation of multiple independent organizations, how we control resource allocation according to committed plans and correspondingly how we handle accounting and billing of resource usage. Besides providing traditional IaaS services, the cloud supports self-service deployment of cloud applications. The cloud thus addresses the long tail of science, allowing researchers of any discipline, without expertise in system or cloud administration, to deploy applications readily available for their perusal.