Skip to content

Commit

Permalink
feat: pg bouncer for pg clusters (#421)
Browse files Browse the repository at this point in the history
* feat: pg bouncer for pg clusters

* docs: updated examples and docs

* fix: plan modifier for pg bouncer

* fix: terraform random update

* feat: pg bouncer data source schema

* fix: updated examples

* docs: update docs

* fix: pg bouncer operation validator

* fix: comments and descriptions

* fix: spell check

* fix: go.sum dependencies

* fix: dependencies update
  • Loading branch information
wai-wong-edb authored Jan 9, 2024
1 parent 16cd83a commit 55fc063
Show file tree
Hide file tree
Showing 19 changed files with 516 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .wordlist-en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ nestedblock
nestedobjatt
pgd
pgextended
pgBouncer
pgvector
postgres
ssd
terraform
Expand Down
28 changes: 28 additions & 0 deletions docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ output "superuser_access" {
value = coalesce(data.biganimal_cluster.this.superuser_access, false)
}
output "pgvector" {
value = coalesce(data.biganimal_cluster.this.pgvector, false)
}
output "faraway_replica_ids" {
value = data.biganimal_cluster.this.faraway_replica_ids
}
Expand Down Expand Up @@ -133,6 +137,7 @@ output "service_account_ids" {
- `faraway_replica_ids` (Set of String)
- `most_recent` (Boolean) Show the most recent cluster when there are multiple clusters with the same name.
- `pe_allowed_principal_ids` (Set of String)
- `pg_bouncer` (Attributes) Pg bouncer. (see [below for nested schema](#nestedatt--pg_bouncer))
- `service_account_ids` (Set of String)

### Read-Only
Expand All @@ -156,6 +161,7 @@ output "service_account_ids" {
- `pg_config` (Attributes Set) Database configuration parameters. (see [below for nested schema](#nestedatt--pg_config))
- `pg_type` (String) Postgres type.
- `pg_version` (String) Postgres version.
- `pgvector` (Boolean) Is pgvector extension enabled. Adds support for vector storage and vector similarity search to Postgres.
- `phase` (String) Current phase of the cluster.
- `private_networking` (Boolean) Is private networking enabled.
- `read_only_connections` (Boolean) Is read only connection enabled.
Expand All @@ -174,6 +180,28 @@ Read-Only:
- `description` (String) CIDR block description.


<a id="nestedatt--pg_bouncer"></a>
### Nested Schema for `pg_bouncer`

Required:

- `is_enabled` (Boolean) Is pg bouncer enabled.

Optional:

- `settings` (Attributes Set) PgBouncer Configuration Settings. (see [below for nested schema](#nestedatt--pg_bouncer--settings))

<a id="nestedatt--pg_bouncer--settings"></a>
### Nested Schema for `pg_bouncer.settings`

Required:

- `name` (String) Name.
- `operation` (String) Operation.
- `value` (String) Value.



<a id="nestedatt--cluster_architecture"></a>
### Nested Schema for `cluster_architecture`

Expand Down
65 changes: 62 additions & 3 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -90,6 +90,23 @@ resource "biganimal_cluster" "single_node_cluster" {
read_only_connections = false
region = "eastus2"
superuser_access = true
pgvector = false
pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}
output "password" {
Expand All @@ -112,7 +129,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -184,6 +201,23 @@ resource "biganimal_cluster" "ha_cluster" {
read_only_connections = true
region = "us-east-1"
superuser_access = true
pgvector = false
pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}
output "password" {
Expand Down Expand Up @@ -224,9 +258,12 @@ output "faraway_replica_ids" {
- `backup_retention_period` (String) Backup retention period. For example, "7d", "2w", or "3m".
- `cluster_architecture` (Block, Optional) Cluster architecture. See [Supported cluster types](https://www.enterprisedb.com/docs/biganimal/latest/overview/02_high_availability/) for details. (see [below for nested schema](#nestedblock--cluster_architecture))
- `csp_auth` (Boolean) Is authentication handled by the cloud service provider. Available for AWS only, See [Authentication](https://www.enterprisedb.com/docs/biganimal/latest/getting_started/creating_a_cluster/#authentication) for details.
- `from_deleted` (Boolean) For restoring a cluster. Specifies if the cluster you want to restore is deleted
- `maintenance_window` (Attributes) Custom maintenance window. (see [below for nested schema](#nestedatt--maintenance_window))
- `pe_allowed_principal_ids` (Set of String) Cloud provider subscription/account ID, need to be specified when cluster is deployed on BigAnimal's cloud account.
- `pg_bouncer` (Attributes) Pg bouncer. (see [below for nested schema](#nestedatt--pg_bouncer))
- `pg_config` (Block Set) Database configuration parameters. See [Modifying database configuration parameters](https://www.enterprisedb.com/docs/biganimal/latest/using_cluster/03_modifying_your_cluster/05_db_configuration_parameters/) for details. (see [below for nested schema](#nestedblock--pg_config))
- `pgvector` (Boolean) Is pgvector extension enabled. Adds support for vector storage and vector similarity search to Postgres.
- `private_networking` (Boolean) Is private networking enabled.
- `read_only_connections` (Boolean) Is read only connection enabled.
- `service_account_ids` (Set of String) A Google Cloud Service Account is used for logs. If you leave this blank, then you will be unable to access log details for this cluster. Required when cluster is deployed on BigAnimal's cloud account.
Expand Down Expand Up @@ -269,7 +306,7 @@ Required:
- `id` (String) Cluster architecture ID. For example, "single" or "ha".For Extreme High Availability clusters, please use the [biganimal_pgd](https://registry.terraform.io/providers/EnterpriseDB/biganimal/latest/docs/resources/pgd) resource.
- `nodes` (Number) Node count.

Read-Only:
Optional:

- `name` (String) Name.

Expand All @@ -287,6 +324,28 @@ Optional:
- `start_time` (String) Start time. "hh:mm", for example: "23:59".


<a id="nestedatt--pg_bouncer"></a>
### Nested Schema for `pg_bouncer`

Required:

- `is_enabled` (Boolean) Is pg bouncer enabled.

Optional:

- `settings` (Attributes Set) PgBouncer Configuration Settings. (see [below for nested schema](#nestedatt--pg_bouncer--settings))

<a id="nestedatt--pg_bouncer--settings"></a>
### Nested Schema for `pg_bouncer.settings`

Required:

- `name` (String) Name.
- `operation` (String) Operation.
- `value` (String) Value.



<a id="nestedblock--pg_config"></a>
### Nested Schema for `pg_config`

Expand Down
20 changes: 18 additions & 2 deletions examples/resources/biganimal_cluster/ha/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -78,7 +78,23 @@ resource "biganimal_cluster" "ha_cluster" {
read_only_connections = true
region = "us-east-1"
superuser_access = true
pgvector = true
pgvector = false

pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}

output "password" {
Expand Down
20 changes: 18 additions & 2 deletions examples/resources/biganimal_cluster/single_node/aws/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -79,7 +79,23 @@ resource "biganimal_cluster" "single_node_cluster" {
read_only_connections = false
region = "us-east-1"
superuser_access = true
pgvector = true
pgvector = false

pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}

output "password" {
Expand Down
20 changes: 18 additions & 2 deletions examples/resources/biganimal_cluster/single_node/azure/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -79,7 +79,23 @@ resource "biganimal_cluster" "single_node_cluster" {
read_only_connections = false
region = "eastus2"
superuser_access = true
pgvector = true
pgvector = false

pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -77,7 +77,23 @@ resource "biganimal_cluster" "single_node_cluster" {
cloud_provider = "bah:aws"
read_only_connections = false
region = "us-east-1"
pgvector = true
pgvector = false

pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -78,7 +78,24 @@ resource "biganimal_cluster" "single_node_cluster" {
cloud_provider = "bah:azure"
read_only_connections = false
region = "eastus2"
pgvector = true
pgvector = false

pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}

# pe_allowed_principal_ids = [
# <example_value> # ex: "9334e5e6-7f47-aE61-5A4F-ee067daeEf4A"
# ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,23 @@ resource "biganimal_cluster" "single_node_cluster" {
cloud_provider = "bah:gcp"
read_only_connections = false
region = "europe-west1"
pgvector = true
pgvector = false

pg_bouncer = {
is_enabled = false
# settings = [ # If is_enabled is true, remove the comment and enter the settings. Should you prefer something different from the defaults.
# {
# name = "autodb_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "5000"
# },
# {
# name = "client_idle_timeout"
# operation = "read-write" #valid values ["read-write", "read-only"]. "read-only" is only valid for ha clusters with read_only_connections set to true
# value = "6000"
# },
# ]
}
}

output "password" {
Expand Down
Loading

0 comments on commit 55fc063

Please sign in to comment.