title: Attaching AWS documentDB to Spring Boot application
body: <p>I've recently tried using the new AWS DocumentDB service as my DB in a Spring application. </p>
  
  <p>The cluster has been created in the same VPC as the EKS on which I deploy my application. Security groups allow connections between all nodes in the VPC. </p>
  
  <p>AWS exposes a mongo URI like this for my DB cluster: </p>
  
  <pre><code>mongodb://&lt;my-user&gt;:&lt;insertYourPassword&gt;@&lt;my-cluster-endpoint&gt;:27017/?ssl_ca_certs=rds-combined-ca-bundle.pem&amp;replicaSet=rs0
  </code></pre>
  
  <p>My question:</p>
  
  <p>How do I make my Spring code work with this kind of connection?</p>
  
  <p>I have tried adding the followig to my <code>application.properties</code> file:</p>
  
  <pre><code>spring.data.mongodb.uri=mongodb://&lt;my-user&gt;:&lt;insertYourPassword&gt;@&lt;my-cluster-endpoint&gt;:27017/admin?ssl_ca_certs=rds-combined-ca-bundle.pem&amp;replicaSet=rs00
  spring.data.mongodb.database=admin
  server.ssl.key-store=classpath:rds-combined-ca-bundle.pem
  </code></pre>
  
  <p>And placing the PEM file in <code>/src/main/resources</code></p>
  
  <p>However the code still fails to connect to the DB cluster.</p>
  
  <p>I get this message as an error: <code>No server chosen by com.mongodb.client.internal.MongoClientDelegate</code></p>
  
  <p>Followed by a <code>Exception in monitor thread while connecting to server ...</code></p>
  
  <p>And finally a timeout exception: <code>com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message</code></p>
  
  <p>It looks kind of like a security group issue but I have no problem connecting with mongo shell from the same EC2 running the Spring application Pod. </p>
  
  <p>Any ideas?  </p>