Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MONGODB as a database engine option #783

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

cnunciato
Copy link
Contributor

@cnunciato cnunciato commented Jan 28, 2022

This change adds MONGODB as an engine option to the databases block of an App spec. It's necessary for anyone wishing to attach an already-existing managed MongoDB cluster to an App Platform app.

From the DigitalOcean docs:

App Platform’s engine support for dev databases is currently limited to PostgresSQL, but you can create a PostgresSQL, MySQL, Redis, or MongoDB managed database with DigitalOcean for use in your app.

Here's a working plan file that uses this change to provision a managed MongoDB cluster and then an App Platform app with a named reference (db) to it:

terraform {
  required_providers {
    digitalocean = {
      source = "digitalocean/digitalocean"
      version = "~> 2.0"
    }
  }
}

variable "do_token" {
    type = string
}

provider "digitalocean" {
  token = var.do_token
}

resource "digitalocean_database_cluster" "cluster" {
  name       = "some-cluster"
  engine     = "mongodb"
  version    = "4"
  size       = "db-s-1vcpu-1gb"
  region     = "sfo3"
  node_count = 1
}

resource "digitalocean_app" "app" {
  spec {
    name   = "some-app"
    region = "sfo3"

    database {
      cluster_name = digitalocean_database_cluster.cluster.name
      name         = "db"
      engine       = "MONGODB"
      production   = true
    }
  }
}
$ terraform apply

digitalocean_database_cluster.cluster: Creating...
digitalocean_database_cluster.cluster: Still creating... [10s elapsed]
...
digitalocean_database_cluster.cluster: Creation complete after 6m8s [id=ce4e5dd1-0927-4e55-adab-6b03347ac280]
digitalocean_app.app: Creating...
digitalocean_app.app: Still creating... [10s elapsed]
digitalocean_app.app: Creation complete after 33s [id=df979d07-53cc-4697-a782-e5a79a3a7339]

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

image

Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks great. Thanks @cnunciato!

@andrewsomething andrewsomething merged commit b9a05d3 into digitalocean:main Jan 28, 2022
@stack72
Copy link
Contributor

stack72 commented Jan 28, 2022

Hey @andrewsomething - any chance of a v2.17.1 for this? ;) We'd love to be able to feature this for a upcoming blog post

@cnunciato
Copy link
Contributor Author

Thank you for the quick response @andrewsomething! 🍻

@andrewsomething
Copy link
Member

Sure thing @stack72 We got you. #784

@MattIPv4
Copy link
Member

Hey, @cnunciato - Thanks a ton for this sweet PR! 😄

Would you please shoot me an email when you get a chance?
mcowley at digitalocean dot com 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants