{"id":19768712,"url":"https://github.com/terraform-do-modules/terraform-digitalocean-database","last_synced_at":"2026-02-12T06:23:11.265Z","repository":{"id":174280486,"uuid":"651990783","full_name":"terraform-do-modules/terraform-digitalocean-database","owner":"terraform-do-modules","description":"Terraform module to create DATABASE resources. DigitalOcean's Managed Databases are a fully managed, high performance database cluster service. Using managed databases is a powerful alternative to installing, configuring, maintaining, and securing databases by hand.","archived":false,"fork":false,"pushed_at":"2024-02-12T18:04:19.000Z","size":51,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-02-12T19:27:54.486Z","etag":null,"topics":["clouddrove","database","devops","digitalocean","digitalocean-container-database","digitalocean-terraform-module","hacktoberfest","iac-terraform","terraform","terraform-module"],"latest_commit_sha":null,"homepage":"https://docs.digitalocean.com/tutorials/databases/","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terraform-do-modules.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-06-10T18:14:52.000Z","updated_at":"2024-01-15T18:40:40.000Z","dependencies_parsed_at":"2024-01-17T20:11:34.824Z","dependency_job_id":"c7081f4d-84ef-4252-ae5b-ce9790cd6070","html_url":"https://github.com/terraform-do-modules/terraform-digitalocean-database","commit_stats":null,"previous_names":["terraform-do-modules/terraform-digitalocean-database"],"tags_count":2,"template":false,"template_full_name":"clouddrove/terraform-module-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-do-modules%2Fterraform-digitalocean-database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-do-modules%2Fterraform-digitalocean-database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-do-modules%2Fterraform-digitalocean-database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-do-modules%2Fterraform-digitalocean-database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terraform-do-modules","download_url":"https://codeload.github.com/terraform-do-modules/terraform-digitalocean-database/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224219758,"owners_count":17275476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clouddrove","database","devops","digitalocean","digitalocean-container-database","digitalocean-terraform-module","hacktoberfest","iac-terraform","terraform","terraform-module"],"created_at":"2024-11-12T04:39:55.253Z","updated_at":"2026-02-12T06:23:11.211Z","avatar_url":"https://github.com/terraform-do-modules.png","language":"HCL","readme":"\u003c!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. --\u003e\n\n\u003cp align=\"center\"\u003e \u003cimg src=\"https://user-images.githubusercontent.com/50652676/62349836-882fef80-b51e-11e9-99e3-7b974309c7e3.png\" width=\"100\" height=\"100\"\u003e\u003c/p\u003e\n\n\n\u003ch1 align=\"center\"\u003e\n    Terraform Module Database\n\u003c/h1\u003e\n\n\u003cp align=\"center\" style=\"font-size: 1.2rem;\"\u003e \n    Terraform module to create Digitalocean database service resource on Digitalocean.\n     \u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\n\u003ca href=\"https://github.com/terraform-do-modules/terraform-digitalocean-database/releases/latest\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/release/terraform-do-modules/terraform-digitalocean-database.svg\" alt=\"Latest Release\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/terraform-do-modules/terraform-digitalocean-database/actions/workflows/tfsec.yml\"\u003e\n  \u003cimg src=\"https://github.com/terraform-do-modules/terraform-digitalocean-database/actions/workflows/tfsec.yml/badge.svg\" alt=\"tfsec\"\u003e\n\u003c/a\u003e\n\u003ca href=\"LICENSE.md\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-APACHE-blue.svg\" alt=\"Licence\"\u003e\n\u003c/a\u003e\n\n\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\n\u003ca href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-module-database'\u003e\n  \u003cimg title=\"Share on Facebook\" src=\"https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png\" /\u003e\n\u003c/a\u003e\n\u003ca href='https://www.linkedin.com/shareArticle?mini=true\u0026title=Terraform+Module+Database\u0026url=https://github.com/clouddrove/terraform-module-database'\u003e\n  \u003cimg title=\"Share on LinkedIn\" src=\"https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png\" /\u003e\n\u003c/a\u003e\n\u003ca href='https://twitter.com/intent/tweet/?text=Terraform+Module+Database\u0026url=https://github.com/clouddrove/terraform-module-database'\u003e\n  \u003cimg title=\"Share on Twitter\" src=\"https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png\" /\u003e\n\u003c/a\u003e\n\n\u003c/p\u003e\n\u003chr\u003e\n\n\nWe eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy \u003cb\u003eBigger problems are always solved by breaking them into smaller manageable problems\u003c/b\u003e. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller \u003cb\u003econnected yet manageable pieces\u003c/b\u003e within the infrastructure. \n\nThis module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.\n\nWe have [*fifty plus terraform modules*][terraform_modules]. A few of them are comepleted and are available for open source usage while a few others are in progress.\n\n\n\n\n## Prerequisites\n\nThis module has a few dependencies: \n- [Terraform 1.5.4](https://learn.hashicorp.com/terraform/getting-started/install.html)\n\n\n\n\n\n\n\n## Examples\n\n\n**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-module-database/releases).\n\n\nHere are examples of how you can use this module in your inventory structure:\n### basic example\n```hcl\n    module \"mysql\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"redis\"\n    cluster_version              = \"6\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    redis_eviction_policy        = \"volatile_lru\"\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"192.168.1.1\"\n      }\n    ]\n  }\n```\n## complete example\n```hcl\n    module \"mysql\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"mysql\"\n    cluster_version              = \"8\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    mysql_sql_mode               = \"ANSI,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES,ALLOW_INVALID_DATES\"\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    databases = [\"testdb\"]\n\n    users = [\n      {\n        name              = \"test\",\n        mysql_auth_plugin = \"mysql_native_password\"\n      }\n    ]\n\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"0.0.0.0\"\n      }\n    ]\n  }\n```\n## mongodb example\n```hcl\n    module \"mongodb\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"mongodb\"\n    cluster_version              = \"6\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    databases = [\"testdb\"]\n    users = [\n      {\n        name = \"test\"\n      }\n    ]\n\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"0.0.0.0\"\n      }\n    ]\n  }\n```\n## mysql example\n```hcl\n    module \"mysql\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"mysql\"\n    cluster_version              = \"8\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    mysql_sql_mode               = \"ANSI,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES,ALLOW_INVALID_DATES\"\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    databases = [\"testdb\"]\n\n    users = [\n      {\n        name              = \"test\",\n        mysql_auth_plugin = \"mysql_native_password\"\n      }\n    ]\n\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"0.0.0.0\"\n      }\n    ]\n  }\n```\n## postgresql example\n```hcl\n    module \"postgresql\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"pg\"\n    cluster_version              = \"15\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    databases = [\"testdb\"]\n    users = [\n      {\n        name = \"test\"\n      }\n    ]\n\n    create_pools = true\n    pools = [\n      {\n        name    = \"test\",\n        mode    = \"transaction\",\n        size    = 10,\n        db_name = \"testdb\",\n        user    = \"test\"\n      }\n    ]\n\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"0.0.0.0\"\n      }\n    ]\n  }\n```\n## redis example\n```hcl\n    module \"redis\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"redis\"\n    cluster_version              = \"6\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    redis_eviction_policy        = \"volatile_lru\"\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"192.168.1.1\"\n      }\n    ]\n  }\n```\n## database replica example\n```hcl\n    module \"redis\" {\n    source                       = \"terraform-do-modules/database/digitalocean\"\n    version                      = \"1.0.0\"\n    name                         = \"app\"\n    environment                  = \"test\"\n    region                       = \"blr1\"\n    cluster_engine               = \"mysql\"\n    cluster_version              = \"8\"\n    cluster_size                 = \"db-s-1vcpu-1gb\"\n    cluster_node_count           = 1\n    cluster_private_network_uuid = module.vpc.id\n    mysql_sql_mode               = \"ANSI,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES,ALLOW_INVALID_DATES\"\n    cluster_maintenance = {\n      maintenance_hour = \"02:00:00\"\n      maintenance_day  = \"saturday\"\n    }\n    databases = [\"testdb\", \"testdbt\"]\n\n    users = [\n      {\n        name              = \"test1\",\n        mysql_auth_plugin = \"mysql_native_password\"\n      }\n    ]\n\n    ## database replica\n    replica_enable = true\n\n    create_firewall = false\n    firewall_rules = [\n      {\n        type  = \"ip_addr\"\n        value = \"0.0.0.0\"\n      }\n    ]\n  }\n```\n\n\n\n\n\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| backup\\_restore | The day and the start hour of the maintenance window policy | `map(string)` | `null` | no |\n| cluster\\_engine | Database engine used by the cluster (ex. pg for PostreSQL, mysql for MySQL, redis for Redis, or mongodb for MongoDB) | `string` | `\"\"` | no |\n| cluster\\_maintenance | The day and the start hour of the maintenance window policy | `map(string)` | `null` | no |\n| cluster\\_node\\_count | Number of nodes that will be included in the cluster | `number` | `1` | no |\n| cluster\\_private\\_network\\_uuid | The ID of the VPC where the database cluster will be located | `string` | `null` | no |\n| cluster\\_size | Database Droplet size associated with the cluster (ex. db-s-1vcpu-1gb) | `string` | `\"db-s-1vcpu-1gb\"` | no |\n| cluster\\_version | The version of the cluster | `string` | `\"\"` | no |\n| create\\_firewall | Controls if firewall should be created | `bool` | `false` | no |\n| create\\_pools | Controls if pools should be created | `bool` | `false` | no |\n| databases | A list of databases in the cluster | `list(string)` | `[]` | no |\n| enabled | Flag to control the resources creation. | `bool` | `true` | no |\n| environment | Environment (e.g. `prod`, `dev`, `staging`). | `string` | `\"\"` | no |\n| firewall\\_rules | List of firewall rules associated with the cluster | `list(map(string))` | `[]` | no |\n| label\\_order | Label order, e.g. `name`,`application`. | `list(any)` | \u003cpre\u003e[\u003cbr\u003e  \"name\",\u003cbr\u003e  \"environment\"\u003cbr\u003e]\u003c/pre\u003e | no |\n| managedby | ManagedBy, eg 'terraform-do-modules' or 'hello@clouddrove.com' | `string` | `\"terraform-do-modules\"` | no |\n| mysql\\_sql\\_mode | A comma separated string specifying the SQL modes for a MySQL cluster. | `string` | `null` | no |\n| name | Name  (e.g. `app` or `cluster`). | `string` | `\"\"` | no |\n| pools | A list of connection pools in the cluster | `list(map(string))` | `null` | no |\n| project\\_id | The ID of the project that the database cluster is assigned to. If excluded when creating a new database cluster, it will be assigned to your default project. | `string` | `null` | no |\n| redis\\_eviction\\_policy | A string specifying the eviction policy for a Redis cluster. Valid values are: noeviction, allkeys\\_lru, allkeys\\_random, volatile\\_lru, volatile\\_random, or volatile\\_ttl | `string` | `null` | no |\n| region | DigitalOcean region where the cluster will reside | `string` | `null` | no |\n| replica\\_enable | Flag to control the resources creation. | `bool` | `false` | no |\n| replica\\_region | DigitalOcean region where the replica will reside | `string` | `null` | no |\n| replica\\_size | Database Droplet size associated with the replica (ex. db-s-1vcpu-1gb). Note that when resizing an existing replica, its size can only be increased. Decreasing its size is not supported. | `string` | `\"db-s-1vcpu-1gb\"` | no |\n| storage\\_size\\_mib | Defines the disk size, in MiB, allocated to the cluster | `string` | `null` | no |\n| users | A list of users in the cluster | `list(map(string))` | `null` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| connection\\_pool\\_host | The hostname used to connect to the database connection pool |\n| connection\\_pool\\_id | The ID of the database connection pool |\n| connection\\_pool\\_password | Password for the connection pool's user |\n| connection\\_pool\\_port | Network port that the database connection pool is listening on |\n| connection\\_pool\\_private\\_host | Same as pool host, but only accessible from resources within the account and in the same region |\n| connection\\_pool\\_private\\_uri | Same as pool uri, but only accessible from resources within the account and in the same region |\n| connection\\_pool\\_uri | The full URI for connecting to the database connection pool |\n| database\\_cluster\\_default\\_database | Name of the cluster's default database |\n| database\\_cluster\\_default\\_password | Password for the cluster's default user |\n| database\\_cluster\\_default\\_user | Username for the cluster's default user |\n| database\\_cluster\\_host | The hostname of the database cluster |\n| database\\_cluster\\_id | The id of the database cluster |\n| database\\_cluster\\_port | Network port that the database cluster is listening on |\n| database\\_cluster\\_private\\_host | Same as host, but only accessible from resources within the account and in the same region |\n| database\\_cluster\\_uri | The full URI for connecting to the database cluster |\n| database\\_cluster\\_urn | The uniform resource name of the database cluster |\n| database\\_firewall\\_id | A unique identifier for the firewall |\n| database\\_firewall\\_rule | A map with rule's uuid, type, value and created\\_at params |\n| database\\_replica\\_firewall\\_rule | A map with rule's uuid, type, value and created\\_at params |\n| db\\_name | The name for the database |\n| replica\\_cluster\\_default\\_database | Name of the replica's default database. |\n| replica\\_cluster\\_default\\_password | Password for the replica cluster's default user |\n| replica\\_cluster\\_default\\_user | Username for the replica cluster's default user |\n| replica\\_cluster\\_port | Network port that the database replica is listening on. |\n| replica\\_cluster\\_private\\_host | Same as host, but only accessible from resources within the account and in the same region. |\n| replica\\_cluster\\_uri | The full URI for connecting to the database replica. |\n| replica\\_host\\_name | The ID of the database replica created by Terraform. |\n| replica\\_id | The ID of the database replica created by Terraform. |\n| user\\_password | Password for the database user |\n| user\\_role | Role for the database user |\n\n\n\n\n## Testing\nIn this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system. \n\nYou need to run the following command in the testing folder:\n```hcl\n  go test -run Test\n```\n\n\n\n## Feedback \nIf you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-module-database/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).\n\nIf you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-module-database)!\n\n## About us\n\nAt [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.\n\n\u003cp align=\"center\"\u003eWe are \u003cb\u003e The Cloud Experts!\u003c/b\u003e\u003c/p\u003e\n\u003chr /\u003e\n\u003cp align=\"center\"\u003eWe ❤️  \u003ca href=\"https://github.com/clouddrove\"\u003eOpen Source\u003c/a\u003e and you can check out \u003ca href=\"https://github.com/clouddrove\"\u003eour other modules\u003c/a\u003e to get help with your new Cloud ideas.\u003c/p\u003e\n\n  [website]: https://clouddrove.com\n  [github]: https://github.com/clouddrove\n  [linkedin]: https://cpco.io/linkedin\n  [twitter]: https://twitter.com/clouddrove/\n  [email]: https://clouddrove.com/contact-us.html\n  [terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93\u0026q=terraform-\u0026type=\u0026language=\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraform-do-modules%2Fterraform-digitalocean-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterraform-do-modules%2Fterraform-digitalocean-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraform-do-modules%2Fterraform-digitalocean-database/lists"}