title: Hibernate database configuration for cloud deployment
body: <p>I'm relatively new to cloud computing and microservices. I know how technologies like <em>aws ec2</em>, <em>ansible</em> and <em>docker swarm</em> work to provision and create a cluster of service in cloud, but I don't still understand how to configure the software for cloud environment (connection parameters for different services, when the IP is unknown until deployment).</p>
  
  <p>I'm used to work with Spring boot and hibernate with bare metal environment and static IP addresses, where I would code service addresses as a properties in pom.xml and inject them in various configuration files depending of the profile for this particular environment. In the end, everything is hard coded somewhere.</p>
  
  <p>Now consider the situation, where I'm automating the whole process of provisioning the environment from cloud and deploying the software, services and database with an ansible script or so. This process would give me server instances with random IP's. It will deploy all the necessary infrastructure components in a single run.</p>
  
  <p>Now how could I configure the software (database connections etc.) when the location of services is unknown at compile time? Should I use DNS? If I do, then what happens when I deploy to different cloud? Is there some more dynamic ways to configure Spring application for cloud environment on docker swarm, maybe make use of some environment variables that swarm manages on the overlay network?</p>
  
  <p>Or am trying to bite too big slice of cake when visualizing in my mind, that with cloud platform and right tools, it is possible to deploy the whole infrastructure to any environment with a single click, from compile to functional, fault tolerant service, without anything hard coded, everything automated?</p>