0

We are trying to connect to aws docdb from errbit, but of no luck. This is the connection string from docdb:

mongodb://user:<insertYourPassword>@dev-docdb-cluster.cluster-xxxx.us-east-1.docdb.amazonaws.com:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0

We are able to connect to Atlas db though, the connection string format we are using for atlas is something like this:

mongodb://user:pass@cluster-shard-00-00-xxx.mongodb.net:27017,cluster-shard-00-01-xxx.mongodb.net:27017,cluster-shard-00-02-xxx.mongodb.net:27017/errbit?ssl=true&replicaSet=Cluster-shard-0&authSource=admin&w=majority
Uladz Kha
  • 2,154
  • 4
  • 40
  • 61

1 Answers1

0

You will need to change config/mongo.rb file to be as follows:

log_level = Logger.const_get Errbit::Config.log_level.upcase

Mongoid.logger.level = log_level
Mongo::Logger.level = log_level

Mongoid.configure do |config|
  uri = if Errbit::Config.mongo_url == 'mongodb://localhost'
          "mongodb://localhost/errbit_#{Rails.env}"
        else
          Errbit::Config.mongo_url
        end

  config.load_configuration(
    clients: {
      default: {
        uri: uri,
        options: { ssl_ca_cert: Rails.root.join('rds-combined-ca-bundle.pem') }
      }
    },
    options: {
      use_activesupport_time_zone: true
    }
  )
end

You can notice that this is exactly the same as current one except for I added: options: { ssl_ca_cert: Rails.root.join('rds-combined-ca-bundle.pem') }

It did work for me after doing this :) Of course you need rds-combined-ca-bundle.pem file to be present at your Rails root folder.

wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

Yes, I've had to create a docker image with the following code:

FROM errbit/errbit:latest
LABEL maintainer="Tarek N. Elsamni <tarek.samni+stackoverflow@gmail.com>"

WORKDIR /app

RUN wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

COPY ["mongo.rb", "/app/config/"]
Tarek N. Elsamni
  • 1,718
  • 1
  • 12
  • 15
  • Thanks for responding @Tarek , i will give it a shot today. Just curious, did you have to create docker image with this change and how about if i have to upgrade in the future! – Arif Khan Aug 23 '19 at 16:45
  • @ArifKhan I've edited the answer to include the docker image I built/used. – Tarek N. Elsamni Aug 25 '19 at 11:52