# Automate Creating New Database Connections

**URL:** <https://forum.inductiveautomation.com/t/automate-creating-new-database-connections/40551>\
**Category:** Ignition\
**Created:** [November 11, 2020, 6:16pm UTC](https://forum.inductiveautomation.com/t/automate-creating-new-database-connections/40551 "2020-11-11T18:16:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [November 11, 2020, 6:17pm UTC](https://forum.inductiveautomation.com/t/automate-creating-new-database-connections/40551/1 "2020-11-11T18:17:00Z")

</div>

We’re working on a system in GCP where we have many different projects (multiples of each tier: Dev, Test, Staging, Prod) and we are regularly destroying old and creating new projects via Terraform. Our Ignition gateway is not a part of these projects and exists in a separate instance that is never destroyed (actually running in AWS). This Ignition gateway needs to connect to all of the MySQL DB instances in every GCP project. With the GCP project creation/destruction being automated it is a bit of a pain to have to create new DB connections to these MySQL instances manually in Ignition. Any thoughts or pointers on how we might be able to make DB connections dynamic/automated?

I’m guessing this isn’t possible outside of a custom module, but figured it’s worth asking. It sounds like future licensing changes may give us some more flexibility here and I may explore having the Ignition gateway included as a separate instance in each GCP project…

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 11, 2020, 6:59pm UTC](https://forum.inductiveautomation.com/t/automate-creating-new-database-connections/40551/2 "2020-11-11T18:59:55Z")

</div>

~~There’s nothing (exposed, supported) in Ignition to dynamically configure DB connections - but could you use a middleman/routing server that (transparent to Ignition) routes to the appropriate DB instance(s) automatically?~~ @MMaynard’s answer is better 🙂

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 11, 2020, 7:04pm UTC](https://forum.inductiveautomation.com/t/automate-creating-new-database-connections/40551/3 "2020-11-11T19:04:51Z")

</div>

Isn’t that what system.db.addDatasource and system.db.removeDatasource are used for?

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [November 11, 2020, 7:10pm UTC](https://forum.inductiveautomation.com/t/automate-creating-new-database-connections/40551/4 "2020-11-11T19:10:25Z")

</div>

Oh wow! I didn’t even realize these existed…this looks like exactly what we need. Thanks!
