digitalocean / terraform-provider-digitalocean

Terraform DigitalOcean provider
https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs
Mozilla Public License 2.0
510 stars 278 forks source link

How can I provision a "Dev Database"? #1205

Closed bartekpacia closed 2 months ago

bartekpacia commented 2 months ago

Basically the question.

I ran:

curl -fsSL -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  "https://api.digitalocean.com/v2/databases/options" \
  | jq '.options.pg'

but I don't see the size for Dev Database:

Screenshot 2024-09-06 at 20 57 02
andrewsomething commented 2 months ago

A "Dev Database" is a component of an App Platform app. It is not a standalone offering and can only be created via App Platform.

See: https://docs.digitalocean.com/products/app-platform/how-to/manage-databases/#connect-to-a-dev-database

With Terraform, you can add a "Dev Database" to an app by adding a database with production = false. For example:

resource "digitalocean_app" "golang-sample" {
  spec {
    name   = "golang-sample"
    region = "nyc"

    service {
      name               = "go-service"
      environment_slug   = "go"
      instance_count     = 1
      instance_size_slug = "apps-s-1vcpu-1gb"

      git {
        repo_clone_url = "https://github.com/digitalocean/sample-golang.git"
        branch         = "main"
      }
    }

    database {
      name       = "dev-db"
      engine     = "PG"
      production = false
    }
  }
}

See: https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/app

bartekpacia commented 2 months ago

I see, thanks a ton!