Question

App Platform - Get database access via API

Hi, I’ve set up a script to deploy automatically new instaces of our app using DigitalOcean Apis.

The script provisiones automatically a MongoDB database and connects it to the app, and everything works fine.

I would like to change the app’s user permissions to only ‘readWrite’, but all the Apis to get the database connection uri don’t return the user password, so I cannot connect to the db from the script.

It’s possible to get the password of the db, or I have to do it manually every time?

Thank you.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

The database values are not available during build time but are available at runtime as environment variables that you could reference directly in your App Platform:

  • ${HOSTNAME}: Fully qualified hostname to the database.
  • ${PORT}: Port to the database.
  • ${USERNAME}: Username for the database.
  • ${PASSWORD}: Password for the database user.

Would this be sufficient for your use case?

Alternatively, if the above does not work for you, the best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.

https://ideas.digitalocean.com/

Hope that helps!

- Bobby.