digitalocean_databaseDigitalOcean released a new managed database service today. It would be nice to manage that resouce via Terraform. This issue is a stub pretty much until godo adds support for the needed API calls that Terraform will use. I've gone ahead about inquired about that support here https://github.com/digitalocean/godo/issues/204.
I forgot to mention that I can certainly add this resource myself once godo is updated. I just need that to get started.
Hi. Thx for this feature. Please keep up posted with new updates.
Thx.
https://github.com/digitalocean/godo/pull/215 was just merged which adds DBaaS support. I expect a release to be cut later today or tomorrow 馃帀
The godo dependency has been updated. I'll start working on this today.
@slapula Thanks for working on this! If for any reason you get blocked, please give me a shout so we can prioritize getting someone to pick up from where you leave off.
@andrewsomething Will do! I'm making good progress on the database resource today and I think I have enough understanding of the API to work on additional database related resources as well once this one is done.
I just submitted digitalocean_database_cluster. I think we could also get away with digitalocean_database and digitalocean_user resources as well.
Based on my review of the API, these functions could also be defined as resources (although I'm not sure if they should exist as independent resources or as attributes of the database or database_cluster resources):
digitalocean_database_replicadigitalocean_database_connection_pooldigitalocean_database_maintenance_windowI think as a general rule of thumb, when you can create multiple "sub-resources" (e.g. replicas and connection pools) they should be independent resources with pointers back to the parent. IMO, it's much simpler implementation wise and is still a reasonable user experience. When there can be only one, like in the case of the maintenance window, nesting it inside the main resource makes sense.
I'd imagine something like:
resource "digitalocean_database_cluster" "foo" {
name = "backend"
engine = "pg"
version = "11"
region = "nyc3"
size = "db-s-2vcpu-4gb"
num_nodes = 2
maintenance_window {
day = "monday"
hour = "16:00"
}
}
resource "digitalocean_database_replica" "read-01" {
primary_node = "${digitalocean_database.foo.id}"
name = "read-replica-01"
region = "nyc3"
size = "db-s-2vcpu-4gb"
}
resource "digitalocean_database_connection_pool" "pool-01" {
database = "${digitalocean_database.foo.id}"
name = "backend-pool"
mode = "transaction"
size = 10
db_name = "defaultdb"
user = "doadmin"
}
One thing to note it that the maintenance window can not currently be set at creation time. It would need to be an additional request after we obtain the ID for the cluster.
One thing to note it that the maintenance window can not currently be set at creation time. It would need to be an additional request after we obtain the ID for the cluster
That's what I noticed as well. I've dealt with calls like this in AWS land by putting them in the update function then pointing the create function to the update function. That's pretty easy to implement.
Initial support for managed databases is now available in v1.12.0. In order to upgrade an existing project to the latest version, run:
terraform init -upgrade
You can find the full changelog here: https://github.com/terraform-providers/terraform-provider-digitalocean/blob/master/CHANGELOG.md#120-april-23-2019
I'm going to go ahead and close this issue out. I will open separate issues to track additional resources (e.g. read replicas and connection pools) independently.
Thanks again for your efforts on this @slapula!
Most helpful comment
https://github.com/digitalocean/godo/pull/215 was just merged which adds DBaaS support. I expect a release to be cut later today or tomorrow 馃帀