paultyng / terraform-provider-sql

https://registry.terraform.io/providers/paultyng/sql/latest/docs
Mozilla Public License 2.0
27 stars 20 forks source link

CloudSQL support and url overrides in resource #47

Open trevex opened 2 years ago

trevex commented 2 years ago

Hi @paultyng ,

I recently stumbled upon this provider and when I was looking into provisioning database instance users with terraform. On GCP there is an API to create users on CloudSQL instances, however they will be created as "superusers". For readonly-users or similar, you have to drop down to SQL. By default CloudSQL instances are not directly reachable, but can be reached through a proxy. Luckily the proxy can be embedded directly in Go and even be used as SQL driver.

I went ahead and implemented a minimal provider myself earlier: https://github.com/trevex/terraform-provider-cloudsql

But if you are open to it I can see if I can draft up a PR implementing CloudSQL-support in this provider.

paultyng commented 2 years ago

I'd be happy to see this added, the only concern I would have is testability. Do you know if there is a free version of CloudSQL it could run against or anything like that?

trevex commented 2 years ago

Unfortunately there is no free tier for CloudSQL and no simulator either, so for tests we will require a real instance or alternatively mock the Dialer used underneath. The latter does not sound appealing to me, so I will reach out to my contacts at Google and see if I can organize a free one.

bitte-ein-bit commented 2 years ago

You might want to check the GoCloud approach which would be universal. I've provided a PR in the past to the MySQL provider that I still have on disk hopefully. if you are interested, I could reupload. https://github.com/winebarrel/terraform-provider-mysql/pull/37