8000 feat: Style polishing by stawii · Pull Request #7 · opsd-io/terraform-module-digitalocean-postgresql · GitHub
[go: up one dir, main page]

Skip to content

feat: Style polishing #7

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

Merged
merged 9 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ module "terraform-module-digitalocean-postgresql" {
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.5 |
| <a name="requirement_digitalocean"></a> [digitalocean](#requirement\_digitalocean) | 2.34.1 |
| <a name="requirement_digitalocean"></a> [digitalocean](#requirement\_digitalocean) | >= 2.34.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_digitalocean"></a> [digitalocean](#provider\_digitalocean) | 2.34.1 |
| <a name="provider_digitalocean"></a> [digitalocean](#provider\_digitalocean) | >= 2.34.1 |

## Modules

Expand All @@ -55,18 +55,18 @@ No modules.

| Name | Type |
|------|------|
| [digitalocean_database_cluster.main](https://registry.terraform.io/providers/digitalocean/digitalocean/2.34.1/docs/resources/database_cluster) | resource |
| [digitalocean_database_firewall.main](https://registry.terraform.io/providers/digitalocean/digitalocean/2.34.1/docs/resources/database_firewall) | resource |
| [digitalocean_database_user.main](https://registry.terraform.io/providers/digitalocean/digitalocean/2.34.1/docs/resources/database_user) | resource |
| [digitalocean_database_cluster.main](https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/database_cluster) | resource |
| [digitalocean_database_firewall.main](https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/database_firewall) | resource |
| [digitalocean_database_user.main](https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/database_user) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the database cluster. | `string` | n/a | yes |
| <a name="input_common_tags"></a> [common\_tags](#input\_common\_tags) | A list of tag names to be applied to the database cluster | `set(string)` | n/a | yes |
| <a name="input_database_users"></a> [database\_users](#input\_database\_users) | List of users | `set(string)` | `[]` | no |
| <a name="input_firewall_rules"></a> [firewall\_rules](#input\_firewall\_rules) | List of trusted sources associated with the cluster | `set(string)` | `[]` | no |
| <a name="input_common_tags"></a> [common\_tags](#input\_common\_tags) | A list of tag names to be applied to the database cluster. | `set(string)` | `[]` | no |
| <a name="input_database_users"></a> [database\_users](#input\_database\_users) | List of users. | `set(string)` | `[]` | no |
| <a name="input_firewall_rules"></a> [firewall\_rules](#input\_firewall\_rules) | List of trusted sources associated with the cluster. | `set(string)` | `[]` | no |
| <a name="input_node_count"></a> [node\_count](#input\_node\_count) | Number of mysql nodes that will be created. | `number` | `1` | no |
| <a name="input_node_size"></a> [node\_size](#input\_node\_size) | The mysql node instance size. | `string` | `"db-s-1vcpu-1gb"` | no |
| <a name="input_postgresql_version"></a> [postgresql\_version](#input\_postgresql\_version) | Engine version used by the cluster. | `number` | `16` | no |
Expand All @@ -76,7 +76,7 @@ No modules.

| Name | Description |
|------|-------------|
| <a name="output_firewall_id"></a> [firewall\_id](#output\_firewall\_id) | A unique identifier for the firewall |
| <a name="output_firewall_id"></a> [firewall\_id](#output\_firewall\_id) | A unique identifier for the firewall. |
| <a name="output_main_default_database"></a> [main\_default\_database](#output\_main\_default\_database) | Name of the cluster's default database. |
| <a name="output_main_default_user"></a> [main\_default\_user](#output\_main\_default\_user) | Username for the cluster's default user. |
| <a name="output_main_default_user_password"></a> [main\_default\_user\_password](#output\_main\_default\_user\_password) | Password for the cluster's default user. |
Expand All @@ -86,7 +86,7 @@ No modules.
| <a name="output_main_private_host"></a> [main\_private\_host](#output\_main\_private\_host) | Same as host, but only accessible from resources within the account and in the same region. |
| <a name="output_main_private_uri"></a> [main\_private\_uri](#output\_main\_private\_uri) | Same as uri, but only accessible from resources within the account and in the same region. |
| <a name="output_main_uri"></a> [main\_uri](#output\_main\_uri) | The full URI for connecting to the database cluster. |
| <a name="output_user_ids"></a> [user\_ids](#output\_user\_ids) | A unique identifier for database users |
| <a name="output_user_ids"></a> [user\_ids](#output\_user\_ids) | A unique identifier for database users. |
<!-- END_TF_DOCS -->

## Examples of usage
Expand Down
5 changes: 3 additions & 2 deletions examples/create_postgresql_database/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module "Digitalocean_postgresql_example" {
source = "github.com/opsd-io/terraform-module-digitalocean-postgresql?ref=2-create-postgresql-terraform-module"
module "example" {
source = "github.com/opsd-io/terraform-module-digitalocean-postgresql?ref=main"

cluster_name = "example-postgresql-cluster"
postgresql_version = "16"
node_size = "db-s-1vcpu-1gb"
Expand Down
33 changes: 23 additions & 10 deletions main.tf
< 10000 td class="blob-num blob-num-expandable" colspan="2"> Expand All
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
terraform {
required_version = ">= 1.5.5"
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = ">= 2.34.1"
}
}
}

resource "digitalocean_database_cluster" "main" {
name = var.cluster_name
engine = "pg"
version = var.postgresql_version
size = var.node_size
region = var.region
node_count = var.node_count
tags = var.common_tags
}

resource "digitalocean_database_firewall" "main" {
cluster_id = digitalocean_database_cluster.main.id

@@ -9,17 +29,10 @@ resource "digitalocean_database_firewall" "main" {
}
}
}

resource "digitalocean_database_user" "main" {
for_each = var.database_users
for_each = var.database_users

cluster_id = digitalocean_database_cluster.main.id
name = each.key
}
resource "digitalocean_database_cluster" "main" {
name = var.cluster_name
engine = "pg"
version = var.postgresql_version
size = var.node_size
region = var.region
node_count = var.node_count
tags = var.common_tags
}
11 changes: 5 additions & 6 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ output "main_port" {

output "main_uri" {
description = "The full URI for connecting to the database cluster."
value = digitalocean_database_cluster.main.uri
sensitive = true
value = digitalocean_database_cluster.main.uri
}

output "main_private_uri" {
description = "Same as uri, but only accessible from resources within the account and in the same region."
value = digitalocean_database_cluster.main.private_uri
sensitive = true
value = digitalocean_database_cluster.main.private_uri
}

output "main_default_database" {
Expand All @@ -42,17 +42,16 @@ output "main_default_user" {

output "main_default_user_password" {
description = "Password for the cluster's default user."
value = digitalocean_database_cluster.main.password
sensitive = true
value = digitalocean_database_cluster.main.password
}

output "firewall_id" {
description = "A unique identifier for the firewall."
value = digitalocean_database_firewall.main.id
description = "A unique identifier for the firewall"
}

output "user_ids" {
description = "A unique identifier for database users"
description = "A unique identifier for database users."
value = [for id in var.database_users : digitalocean_database_user.main[id].id]

}
9 changes: 6 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ variable "cluster_name" {
type = string
nullable = false
}

variable "node_count" {
description = "Number of mysql nodes that will be created."
type = number
default = 1
}

variable "node_size" {
description = "The mysql node instance size."
type = string
Expand All @@ -27,18 +29,19 @@ variable "region" {
}

variable "common_tags" {
description = "A list of tag names to be applied to the database cluster"
description = "A list of tag names to be applied to the database cluster."
type = set(string)
default = []
}

variable "firewall_rules" {
description = "List of trusted sources associated with the cluster"
description = "List of trusted sources associated with the cluster."
type = set(string)
default = []
}

variable "database_users" {
description = "List of users"
description = "List of users."
type = set(string)
default = []
}
9 changes: 0 additions & 9 deletions versions.tf

This file was deleted.

0