hashicorp / terraform-azurerm-terraform-enterprise

A Terraform module for deploying Terraform Enterprise on Azure.
Mozilla Public License 2.0
67 stars 61 forks source link

production db seeding #58

Open ausfestivus opened 4 years ago

ausfestivus commented 4 years ago

Evening,

Quick Q. Im working on an Azure production deployment stack for TFE using this module. The stack creates the necessary Storage Account and Postgres DB for the production deployment. I can pass the attributes for these resources into the TFE module, no problem.

The tricky part is to seed the database with the necessary SQL. Anyone got any tips to share on solving this need?

Im going to be scouring the internet looking for a suitable and workable approach. Figured I would put it here as well to see if any Hashicorp or other TFE users have solved this?

At the back of my mind is to actually put the SA and DBS provisioning into an entirely seperate TF stack. That would give me more flexibility I think and also achieve a nice logical separation between the TFE app layer and a persistent data layer.

erindatkinson commented 4 years ago

That's (separate state for data layer) definitely an option, I've done similar things and used a remote state data source to pull the resulting resource parameters. Using a postgres provider in the data layer environment, you should be able to set up the database/schemas/extensions pretty consistently and be able to either implicitly or explicitly set the dependency.

ausfestivus commented 4 years ago

Hey @erindatkinson, I got all excited about using the postgresql provider to do the DB seeding but then I ran into https://github.com/terraform-providers/terraform-provider-postgresql/issues/2 at a screaming pace.

Le sigh.

ausfestivus commented 4 years ago

A wild blocker appeared. https://github.com/terraform-providers/terraform-provider-postgresql/issues/107

ausfestivus commented 4 years ago

https://github.com/terraform-providers/terraform-provider-postgresql/issues/2 has now been closed with a fix/workaround. Im going to rework this to see if it does indeed work as advertised and will update this accordingly.