89 lines
5.5 KiB
Markdown
89 lines
5.5 KiB
Markdown
|
# AlloyDB cluster and instance with read replicas
|
||
|
|
||
|
This module manages the creation of AlloyDB cluster and configuration with/without automated backup policy, Primary node instance and Read Node Pools.
|
||
|
|
||
|
|
||
|
## Simple example
|
||
|
|
||
|
This example shows how to create Alloydb cluster and instance with multiple read pools in GCP project.
|
||
|
|
||
|
```hcl
|
||
|
module "alloydb" {
|
||
|
source = "./fabric/modules/alloydb-instance"
|
||
|
project_id = "myproject"
|
||
|
cluster_id = "alloydb-cluster-all"
|
||
|
location = "europe-west2"
|
||
|
labels = {}
|
||
|
display_name = ""
|
||
|
initial_user = {
|
||
|
user = "alloydb-cluster-full",
|
||
|
password = "alloydb-cluster-password"
|
||
|
}
|
||
|
network_self_link = "projects/myproject/global/networks/default"
|
||
|
|
||
|
automated_backup_policy = null
|
||
|
|
||
|
primary_instance_config = {
|
||
|
instance_id = "primary-instance-1",
|
||
|
instance_type = "PRIMARY",
|
||
|
machine_cpu_count = 2,
|
||
|
database_flags = {},
|
||
|
display_name = "alloydb-primary-instance"
|
||
|
}
|
||
|
read_pool_instance = [
|
||
|
{
|
||
|
instance_id = "read-instance-1",
|
||
|
display_name = "read-instance-1",
|
||
|
instance_type = "READ_POOL",
|
||
|
node_count = 1,
|
||
|
database_flags = {},
|
||
|
machine_cpu_count = 1
|
||
|
},
|
||
|
{
|
||
|
instance_id = "read-instance-2",
|
||
|
display_name = "read-instance-2",
|
||
|
instance_type = "READ_POOL",
|
||
|
node_count = 1,
|
||
|
database_flags = {},
|
||
|
machine_cpu_count = 1
|
||
|
}
|
||
|
]
|
||
|
|
||
|
}
|
||
|
|
||
|
# tftest modules=1 resources=7
|
||
|
```
|
||
|
## TODO
|
||
|
- [ ] Add IAM support
|
||
|
- [ ] support password in output
|
||
|
<!-- BEGIN TFDOC -->
|
||
|
|
||
|
## Variables
|
||
|
|
||
|
| name | description | type | required | default |
|
||
|
|---|---|:---:|:---:|:---:|
|
||
|
| [cluster_id](variables.tf#L35) | The ID of the alloydb cluster. | <code>string</code> | ✓ | |
|
||
|
| [network_self_link](variables.tf#L83) | Network ID where the AlloyDb cluster will be deployed. | <code>string</code> | ✓ | |
|
||
|
| [primary_instance_config](variables.tf#L88) | Primary cluster configuration that supports read and write operations. | <code title="object({ instance_id = string, display_name = optional(string), database_flags = optional(map(string)) labels = optional(map(string)) annotations = optional(map(string)) gce_zone = optional(string) availability_type = optional(string) machine_cpu_count = optional(number, 2), })">object({…})</code> | ✓ | |
|
||
|
| [project_id](variables.tf#L110) | The ID of the project in which to provision resources. | <code>string</code> | ✓ | |
|
||
|
| [automated_backup_policy](variables.tf#L17) | The automated backup policy for this cluster. | <code title="object({ location = optional(string) backup_window = optional(string) enabled = optional(bool) weekly_schedule = optional(object({ days_of_week = optional(list(string)) start_times = list(string) })), quantity_based_retention_count = optional(number) time_based_retention_count = optional(string) labels = optional(map(string)) backup_encryption_key_name = optional(string) })">object({…})</code> | | <code>null</code> |
|
||
|
| [display_name](variables.tf#L44) | Human readable display name for the Alloy DB Cluster. | <code>string</code> | | <code>null</code> |
|
||
|
| [encryption_key_name](variables.tf#L50) | The fully-qualified resource name of the KMS key for cluster encryption. | <code>string</code> | | <code>null</code> |
|
||
|
| [initial_user](variables.tf#L56) | Alloy DB Cluster Initial User Credentials. | <code title="object({ user = optional(string), password = string })">object({…})</code> | | <code>null</code> |
|
||
|
| [labels](variables.tf#L65) | User-defined labels for the alloydb cluster. | <code>map(string)</code> | | <code>{}</code> |
|
||
|
| [location](variables.tf#L71) | Location where AlloyDb cluster will be deployed. | <code>string</code> | | <code>"europe-west2"</code> |
|
||
|
| [network_name](variables.tf#L77) | The network name of the project in which to provision resources. | <code>string</code> | | <code>"multiple-readpool"</code> |
|
||
|
| [read_pool_instance](variables.tf#L115) | List of Read Pool Instances to be created. | <code title="list(object({ instance_id = string display_name = string node_count = optional(number, 1) database_flags = optional(map(string)) availability_type = optional(string) gce_zone = optional(string) machine_cpu_count = optional(number, 2) }))">list(object({…}))</code> | | <code>[]</code> |
|
||
|
|
||
|
## Outputs
|
||
|
|
||
|
| name | description | sensitive |
|
||
|
|---|---|:---:|
|
||
|
| [cluster](outputs.tf#L17) | Cluster created. | ✓ |
|
||
|
| [cluster_id](outputs.tf#L23) | ID of the Alloy DB Cluster created. | |
|
||
|
| [primary_instance](outputs.tf#L28) | Primary instance created. | |
|
||
|
| [primary_instance_id](outputs.tf#L33) | ID of the primary instance created. | |
|
||
|
| [read_pool_instance_ids](outputs.tf#L38) | IDs of the read instances created. | |
|
||
|
|
||
|
<!-- END TFDOC -->
|