terraform-digitalocean-database
Terraform module which creates a DigitalOcean database cluster resource.
module "database" {
source = " ../../"
cluster_name = " postgresql-fra1"
cluster_engine = " pg"
cluster_version = " 13"
cluster_size = " db-s-2vcpu-4gb"
cluster_region = " fra1"
cluster_node_count = 2
cluster_private_network_uuid = digitalocean_vpc. foo-bar-vpc . id
cluster_tags = [" foo" , " bar" ]
cluster_maintenance = {
maintenance_hour = " 02:00:00"
maintenance_day = " saturday"
}
databases = [" foo-database" , " bar-database" ]
users = [
{
name = " foo-user"
},
{
name = " bar-user"
}
]
create_pools = true
pools = [
{
name = " foo-pool" ,
mode = " transaction" ,
size = 10 ,
db_name = " foo-database" ,
user = " foo-user"
},
{
name = " bar-pool"
mode = " transaction" ,
size = 10 ,
db_name = " bar-database" ,
user = " bar-user"
}
]
create_firewall = true
firewall_rules = [
{
type = " droplet" ,
value = digitalocean_droplet.web.id
}
]
}
Some complete examples can be found in this repository:
No modules.
Name
Description
Type
Default
Required
cluster_engine
Database engine used by the cluster (ex. pg for PostreSQL, mysql for MySQL, redis for Redis, or mongodb for MongoDB)
string
n/a
yes
cluster_maintenance
The day and the start hour of the maintenance window policy
map(string)
null
no
cluster_name
The name of the cluster
string
n/a
yes
cluster_node_count
Number of nodes that will be included in the cluster
number
n/a
yes
cluster_private_network_uuid
The ID of the VPC where the database cluster will be located
string
null
no
cluster_region
DigitalOcean region where the cluster will reside
string
n/a
yes
cluster_size
Database Droplet size associated with the cluster (ex. db-s-1vcpu-1gb)
string
n/a
yes
cluster_tags
A list of optional tags to add to the cluster
list(string)
[]
no
cluster_version
The version of the cluster
string
n/a
yes
create_firewall
Controls if firewall should be created
bool
false
no
create_pools
Controls if pools should be created
bool
false
no
databases
A list of databases in the cluster
list(string)
[]
no
firewall_rules
List of firewall rules associated with the cluster
list(map(string))
[]
no
mysql_sql_mode
A comma separated string specifying the SQL modes for a MySQL cluster.
string
null
no
pools
A list of connection pools in the cluster
list(map(string))
null
no
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
users
A list of users in the cluster
list(map(string))
null
no