4

recently AWS implemented compatibility with MongoDB version 3.6 via DocumentDB.

Document DB requires a certificate that can be downloaded at:

https://s3-us-gov-west-1.amazonaws.com/rds-downloads/rds-GovCloud-Root-CA-2017.pem

Using a configuration file similar to:

https://github.com/mongodb/mongoid/blob/master/lib/rails/generators/mongoid/config/templates/mongoid.yml

I would like to know if there is a way to set compatibility with 3.6 in mongoid gem or if there is a specific version that ensures that version 3.6 is used?

Thank you

ipegasus
  • 14,796
  • 9
  • 52
  • 76

4 Answers4

2

First, it is important to note that DocumentDB implements only partial compatibility with "MongoDB 3.6" as Amazon advertises. You can read more about some of the incompatibilities here: https://www.mongodb.com/blog/post/documents-are-everywhere

Mongoid works, and is tested, with the actual MongoDB 3.6 server. No special configuration is needed.

Using Mongoid with DocumentDB may work or may expose incompatibilities/omissions in Amazon's document database, depending on exact operations attempted.

D. SM
  • 13,584
  • 3
  • 12
  • 21
  • Thank you! It worked on most DB tables. But not for geo spatial queries. Hopefully support will be added in the future. – ipegasus Nov 29 '20 at 16:08
2

First, you may need to download the RDS combined bundle as opposed to the rds-GovCloud-Root-CA-2017.pem. Link: https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

Try this as your yaml file:

development:
  clients:
    default:
      uri: mongodb://myuser:mypassword@<your_cluster_endpoint>:<cluster_port>/test?ssl=true
      options:
        ssl_ca_cert: /path/to/rds-combined-ca-bundle.pem
  • 1
    When I tried this, I got `Mongoid::Errors::MixedClientConfiguration: message: Both uri and standard configuration options defined for client: 'default'.`. You have to put all the options as query parameters on the uri or switch from uri do hosts and put all the options in the yaml – eriese Feb 01 '20 at 05:02
  • Can you elaborate, @eriese ? what was the final connection information that worked? – OpenGears Dec 09 '20 at 10:48
  • @Nanofunk, I had to stop using DocumentDB because I needed functionality they don't support, but here's my [mongoid.yml](https://github.com/eriese/bedpost/blob/005d67471cbf49c044548a6cdbef4b254933e931/config/mongoid.yml) from when I had it working. Check out the production config and let me know if that's helpful or needs more explanation. – eriese Dec 10 '20 at 13:43
0

Sample Working Configuration

production:
    clients:
        default:
            uri: "mongodb://user:pass@db_end_point:27017/db_name?ssl=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false"
            app_name: AppName
            options:
                ssl_ca_cert: "./config/rds-combined-ca-bundle.pem"

development:
    clients:
        default:
            uri: "mongodb://user:pass@db_end_point:27017/db_name?ssl=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false"
            app_name: AppName
            options:
                ssl_ca_cert: "./config/rds-combined-ca-bundle.pem"


test:
    clients:
        default:
            uri: "mongodb://user:pass@db_end_point:27017/db_name?ssl=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false"
            app_name: AppName
            options:
                ssl_ca_cert: "./config/rds-combined-ca-bundle.pem"
ipegasus
  • 14,796
  • 9
  • 52
  • 76
0

as of 2022, aws provided uri with protocol(mongodb://) and query seems not working with mongoid..?

( as I got error below

Mongoid::Errors::MixedClientConfiguration: message: Both uri and standard configuration options defined for client: 'default'.

then, I modified config/mongoid.yml

working example should be like this:


development:
  clients:
    default:
      database: your_db
      hosts:
        - xxx.ap-northeast-1.docdb.amazonaws.com:27017
      options:
        user: mongo_user
        password: password
        ssl: true
        ssl_verify: false
        ssl_cert: path/to/rds-combined-ca-bundle.pem

reference:

https://github.com/mongodb/mongoid/blob/master/lib/rails/generators/mongoid/config/templates/mongoid.yml

satio2000
  • 1
  • 1