Skip to content

Commit 42d69ad

Browse files
committed
update README.md
1 parent 32a6b65 commit 42d69ad

File tree

1 file changed

+314
-21
lines changed

1 file changed

+314
-21
lines changed

README.md

Lines changed: 314 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55

66
<h1 align="center">
7-
Terraform Module Template
7+
Terraform Module Database
88
</h1>
99

1010
<p align="center" style="font-size: 1.2rem;">
11-
Terraform module template to create new modules using this as baseline
11+
Terraform module to create Digitalocean database service resource on Digitalocean.
1212
</p>
1313

1414
<p align="center">
1515

16-
<a href="https://github.com/clouddrove/terraform-module-template/releases/latest">
17-
<img src="https://img.shields.io/github/release/clouddrove/terraform-module-template.svg" alt="Latest Release">
16+
<a href="https://github.com/terraform-do-modules/terraform-digitalocean-database/releases/latest">
17+
<img src="https://img.shields.io/github/release/terraform-do-modules/terraform-digitalocean-database.svg" alt="Latest Release">
1818
</a>
19-
<a href="">
20-
<img src="https://github.com/clouddrove/terraform-module-template/actions/workflows/tfsec.yml/badge.svg" alt="tfsec">
19+
<a href="https://github.com/terraform-do-modules/terraform-digitalocean-database/actions/workflows/tfsec.yml">
20+
<img src="https://github.com/terraform-do-modules/terraform-digitalocean-database/actions/workflows/tfsec.yml/badge.svg" alt="tfsec">
2121
</a>
2222
<a href="LICENSE.md">
2323
<img src="https://img.shields.io/badge/License-APACHE-blue.svg" alt="Licence">
@@ -27,13 +27,13 @@
2727
</p>
2828
<p align="center">
2929

30-
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-module-template'>
30+
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-module-database'>
3131
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
3232
</a>
33-
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+Module+Template&url=https://github.com/clouddrove/terraform-module-template'>
33+
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+Module+Database&url=https://github.com/clouddrove/terraform-module-database'>
3434
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
3535
</a>
36-
<a href='https://twitter.com/intent/tweet/?text=Terraform+Module+Template&url=https://github.com/clouddrove/terraform-module-template'>
36+
<a href='https://twitter.com/intent/tweet/?text=Terraform+Module+Database&url=https://github.com/clouddrove/terraform-module-database'>
3737
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
3838
</a>
3939

@@ -53,11 +53,7 @@ We have [*fifty plus terraform modules*][terraform_modules]. A few of them are c
5353
## Prerequisites
5454

5555
This module has a few dependencies:
56-
57-
- [Terraform 1.x.x](https://learn.hashicorp.com/terraform/getting-started/install.html)
58-
- [Go](https://golang.org/doc/install)
59-
- [github.com/stretchr/testify/assert](https://github.com/stretchr/testify)
60-
- [github.com/gruntwork-io/terratest/modules/terraform](https://github.com/gruntwork-io/terratest)
56+
- [Terraform 1.5.4](https://learn.hashicorp.com/terraform/getting-started/install.html)
6157

6258

6359

@@ -68,12 +64,252 @@ This module has a few dependencies:
6864
## Examples
6965

7066

71-
**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-template/releases).
67+
**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).
7268

7369

74-
Here are some examples of how you can use this module in your inventory structure:
70+
Here are examples of how you can use this module in your inventory structure:
71+
### basic example
72+
```hcl
73+
module "mysql" {
74+
source = "terraform-do-modules/database/digitalocean"
75+
version = "1.0.0"
76+
name = "app"
77+
environment = "test"
78+
region = "blr1"
79+
cluster_engine = "redis"
80+
cluster_version = "6"
81+
cluster_size = "db-s-1vcpu-1gb"
82+
cluster_node_count = 1
83+
cluster_private_network_uuid = module.vpc.id
84+
redis_eviction_policy = "volatile_lru"
85+
cluster_maintenance = {
86+
maintenance_hour = "02:00:00"
87+
maintenance_day = "saturday"
88+
}
89+
create_firewall = false
90+
firewall_rules = [
91+
{
92+
type = "ip_addr"
93+
value = "192.168.1.1"
94+
}
95+
]
96+
}
97+
```
98+
## complete example
99+
```hcl
100+
module "mysql" {
101+
source = "terraform-do-modules/database/digitalocean"
102+
version = "1.0.0"
103+
name = "app"
104+
environment = "test"
105+
region = "blr1"
106+
cluster_engine = "mysql"
107+
cluster_version = "8"
108+
cluster_size = "db-s-1vcpu-1gb"
109+
cluster_node_count = 1
110+
cluster_private_network_uuid = module.vpc.id
111+
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"
112+
cluster_maintenance = {
113+
maintenance_hour = "02:00:00"
114+
maintenance_day = "saturday"
115+
}
116+
databases = ["testdb"]
117+
118+
users = [
119+
{
120+
name = "test",
121+
mysql_auth_plugin = "mysql_native_password"
122+
}
123+
]
124+
125+
create_firewall = false
126+
firewall_rules = [
127+
{
128+
type = "ip_addr"
129+
value = "0.0.0.0"
130+
}
131+
]
132+
}
133+
```
134+
## mongodb example
135+
```hcl
136+
module "mongodb" {
137+
source = "terraform-do-modules/database/digitalocean"
138+
version = "1.0.0"
139+
name = "app"
140+
environment = "test"
141+
region = "blr1"
142+
cluster_engine = "mongodb"
143+
cluster_version = "6"
144+
cluster_size = "db-s-1vcpu-1gb"
145+
cluster_node_count = 1
146+
cluster_private_network_uuid = module.vpc.id
147+
cluster_maintenance = {
148+
maintenance_hour = "02:00:00"
149+
maintenance_day = "saturday"
150+
}
151+
databases = ["testdb"]
152+
users = [
153+
{
154+
name = "test"
155+
}
156+
]
157+
158+
create_firewall = false
159+
firewall_rules = [
160+
{
161+
type = "ip_addr"
162+
value = "0.0.0.0"
163+
}
164+
]
165+
}
166+
```
167+
## mysql example
75168
```hcl
76-
```
169+
module "mysql" {
170+
source = "terraform-do-modules/database/digitalocean"
171+
version = "1.0.0"
172+
name = "app"
173+
environment = "test"
174+
region = "blr1"
175+
cluster_engine = "mysql"
176+
cluster_version = "8"
177+
cluster_size = "db-s-1vcpu-1gb"
178+
cluster_node_count = 1
179+
cluster_private_network_uuid = module.vpc.id
180+
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"
181+
cluster_maintenance = {
182+
maintenance_hour = "02:00:00"
183+
maintenance_day = "saturday"
184+
}
185+
databases = ["testdb"]
186+
187+
users = [
188+
{
189+
name = "test",
190+
mysql_auth_plugin = "mysql_native_password"
191+
}
192+
]
193+
194+
create_firewall = false
195+
firewall_rules = [
196+
{
197+
type = "ip_addr"
198+
value = "0.0.0.0"
199+
}
200+
]
201+
}
202+
```
203+
## postgresql example
204+
```hcl
205+
module "postgresql" {
206+
source = "terraform-do-modules/database/digitalocean"
207+
version = "1.0.0"
208+
name = "app"
209+
environment = "test"
210+
region = "blr1"
211+
cluster_engine = "pg"
212+
cluster_version = "15"
213+
cluster_size = "db-s-1vcpu-1gb"
214+
cluster_node_count = 1
215+
cluster_private_network_uuid = module.vpc.id
216+
cluster_maintenance = {
217+
maintenance_hour = "02:00:00"
218+
maintenance_day = "saturday"
219+
}
220+
databases = ["testdb"]
221+
users = [
222+
{
223+
name = "test"
224+
}
225+
]
226+
227+
create_pools = true
228+
pools = [
229+
{
230+
name = "test",
231+
mode = "transaction",
232+
size = 10,
233+
db_name = "testdb",
234+
user = "test"
235+
}
236+
]
237+
238+
create_firewall = false
239+
firewall_rules = [
240+
{
241+
type = "ip_addr"
242+
value = "0.0.0.0"
243+
}
244+
]
245+
}
246+
```
247+
## redis example
248+
```hcl
249+
module "redis" {
250+
source = "terraform-do-modules/database/digitalocean"
251+
version = "1.0.0"
252+
name = "app"
253+
environment = "test"
254+
region = "blr1"
255+
cluster_engine = "redis"
256+
cluster_version = "6"
257+
cluster_size = "db-s-1vcpu-1gb"
258+
cluster_node_count = 1
259+
cluster_private_network_uuid = module.vpc.id
260+
redis_eviction_policy = "volatile_lru"
261+
cluster_maintenance = {
262+
maintenance_hour = "02:00:00"
263+
maintenance_day = "saturday"
264+
}
265+
create_firewall = false
266+
firewall_rules = [
267+
{
268+
type = "ip_addr"
269+
value = "192.168.1.1"
270+
}
271+
]
272+
}
273+
```
274+
## database replica example
275+
```hcl
276+
module "redis" {
277+
source = "terraform-do-modules/database/digitalocean"
278+
version = "1.0.0"
279+
name = "app"
280+
environment = "test"
281+
region = "blr1"
282+
cluster_engine = "mysql"
283+
cluster_version = "8"
284+
cluster_size = "db-s-1vcpu-1gb"
285+
cluster_node_count = 1
286+
cluster_private_network_uuid = module.vpc.id
287+
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"
288+
cluster_maintenance = {
289+
maintenance_hour = "02:00:00"
290+
maintenance_day = "saturday"
291+
}
292+
databases = ["testdb", "testdbt"]
293+
294+
users = [
295+
{
296+
name = "test1",
297+
mysql_auth_plugin = "mysql_native_password"
298+
}
299+
]
300+
301+
## database replica
302+
replica_enable = true
303+
304+
create_firewall = false
305+
firewall_rules = [
306+
{
307+
type = "ip_addr"
308+
value = "0.0.0.0"
309+
}
310+
]
311+
}
312+
```
77313

78314

79315

@@ -82,11 +318,68 @@ Here are some examples of how you can use this module in your inventory structur
82318

83319
## Inputs
84320

85-
No input.
321+
| Name | Description | Type | Default | Required |
322+
|------|-------------|------|---------|:--------:|
323+
| backup\_restore | The day and the start hour of the maintenance window policy | `map(string)` | `null` | no |
324+
| cluster\_engine | Database engine used by the cluster (ex. pg for PostreSQL, mysql for MySQL, redis for Redis, or mongodb for MongoDB) | `string` | `""` | no |
325+
| cluster\_maintenance | The day and the start hour of the maintenance window policy | `map(string)` | `null` | no |
326+
| cluster\_node\_count | Number of nodes that will be included in the cluster | `number` | `1` | no |
327+
| cluster\_private\_network\_uuid | The ID of the VPC where the database cluster will be located | `string` | `null` | no |
328+
| cluster\_size | Database Droplet size associated with the cluster (ex. db-s-1vcpu-1gb) | `string` | `"db-s-1vcpu-1gb"` | no |
329+
| cluster\_version | The version of the cluster | `string` | `""` | no |
330+
| create\_firewall | Controls if firewall should be created | `bool` | `false` | no |
331+
| create\_pools | Controls if pools should be created | `bool` | `false` | no |
332+
| databases | A list of databases in the cluster | `list(string)` | `[]` | no |
333+
| enabled | Flag to control the resources creation. | `bool` | `true` | no |
334+
| environment | Environment (e.g. `prod`, `dev`, `staging`). | `string` | `""` | no |
335+
| firewall\_rules | List of firewall rules associated with the cluster | `list(map(string))` | `[]` | no |
336+
| label\_order | Label order, e.g. `name`,`application`. | `list(any)` | <pre>[<br> "name",<br> "environment"<br>]</pre> | no |
337+
| managedby | ManagedBy, eg 'terraform-do-modules' or '[email protected]' | `string` | `"terraform-do-modules"` | no |
338+
| mysql\_sql\_mode | A comma separated string specifying the SQL modes for a MySQL cluster. | `string` | `null` | no |
339+
| name | Name (e.g. `app` or `cluster`). | `string` | `""` | no |
340+
| pools | A list of connection pools in the cluster | `list(map(string))` | `null` | no |
341+
| 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 |
342+
| 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 |
343+
| region | DigitalOcean region where the cluster will reside | `string` | `null` | no |
344+
| replica\_enable | Flag to control the resources creation. | `bool` | `false` | no |
345+
| replica\_region | DigitalOcean region where the replica will reside | `string` | `null` | no |
346+
| 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 |
347+
| users | A list of users in the cluster | `list(map(string))` | `null` | no |
86348

87349
## Outputs
88350

89-
No output.
351+
| Name | Description |
352+
|------|-------------|
353+
| connection\_pool\_host | The hostname used to connect to the database connection pool |
354+
| connection\_pool\_id | The ID of the database connection pool |
355+
| connection\_pool\_password | Password for the connection pool's user |
356+
| connection\_pool\_port | Network port that the database connection pool is listening on |
357+
| connection\_pool\_private\_host | Same as pool host, but only accessible from resources within the account and in the same region |
358+
| connection\_pool\_private\_uri | Same as pool uri, but only accessible from resources within the account and in the same region |
359+
| connection\_pool\_uri | The full URI for connecting to the database connection pool |
360+
| database\_cluster\_default\_database | Name of the cluster's default database |
361+
| database\_cluster\_default\_password | Password for the cluster's default user |
362+
| database\_cluster\_default\_user | Username for the cluster's default user |
363+
| database\_cluster\_host | The hostname of the database cluster |
364+
| database\_cluster\_id | The id of the database cluster |
365+
| database\_cluster\_port | Network port that the database cluster is listening on |
366+
| database\_cluster\_private\_host | Same as host, but only accessible from resources within the account and in the same region |
367+
| database\_cluster\_uri | The full URI for connecting to the database cluster |
368+
| database\_cluster\_urn | The uniform resource name of the database cluster |
369+
| database\_firewall\_id | A unique identifier for the firewall |
370+
| database\_firewall\_rule | A map with rule's uuid, type, value and created\_at params |
371+
| database\_replica\_firewall\_rule | A map with rule's uuid, type, value and created\_at params |
372+
| db\_name | The name for the database |
373+
| replica\_cluster\_default\_database | Name of the replica's default database. |
374+
| replica\_cluster\_default\_password | Password for the replica cluster's default user |
375+
| replica\_cluster\_default\_user | Username for the replica cluster's default user |
376+
| replica\_cluster\_port | Network port that the database replica is listening on. |
377+
| replica\_cluster\_private\_host | Same as host, but only accessible from resources within the account and in the same region. |
378+
| replica\_cluster\_uri | The full URI for connecting to the database replica. |
379+
| replica\_host\_name | The ID of the database replica created by Terraform. |
380+
| replica\_id | The ID of the database replica created by Terraform. |
381+
| user\_password | Password for the database user |
382+
| user\_role | Role for the database user |
90383

91384

92385

@@ -102,9 +395,9 @@ You need to run the following command in the testing folder:
102395

103396

104397
## Feedback
105-
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-module-template/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
398+
If 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 [[email protected]](mailto:[email protected]).
106399

107-
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-module-template)!
400+
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-module-database)!
108401

109402
## About us
110403

0 commit comments

Comments
 (0)