Cloud applications are web-based distributed systems deployed over a fluctuating set of computing nodes and services. The design of cloud applications is particularly challenging because few assumptions can be made about the connectivity of nodes, the availability of services, as well as how the computing fabric will evolve in the long term. In this paper we show that logic programming combined with novel abstractions can be used to specify and synthesize cloud applications. Our tool-suite, called BAM, allows cloud applications to be specified independently from implementation technologies. The declarative nature of logic programming is essential to produce this decoupling. Code synthesis integrates state-of-the-art web technologies with well-known algorithms from logic programming to produce realistic and complete implementations from BAM specifications. First experiments show that mixing declarative logic programming with novel communication abstractions yields a powerful framework for architecting nextgeneration distributed systems.