|
1 | 1 | <!-- BEGIN MODULE HOOK -->
|
2 | 2 |
|
3 | 3 | <!-- Update the title to match the module name and add a description -->
|
4 |
| -# Terraform Modules Template Project |
| 4 | +# IBM Cloud Databases for ICD Postgresql module |
5 | 5 | <!-- UPDATE BADGE: Update the link for the following badge-->
|
6 | 6 | [-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
|
7 | 7 | [](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/actions/workflows/ci.yml)
|
8 | 8 | [](https://github.com/pre-commit/pre-commit)
|
9 |
| -[](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/releases/latest) |
| 9 | +[](https://github.com/terraform-ibm-modules/terraform-ibm-icd-postgresql/releases/latest) |
10 | 10 | [](https://renovatebot.com/)
|
11 | 11 | [](https://github.com/semantic-release/semantic-release)
|
12 | 12 |
|
13 |
| -<!-- Remove the content in this H2 heading after completing the steps --> |
14 |
| - |
15 |
| -## Submit a new module |
16 |
| - |
17 |
| -:+1::tada: Thank you for taking the time to contribute! :tada::+1: |
18 |
| - |
19 |
| -This template repository exists to help you create Terraform modules for IBM Cloud. |
20 |
| - |
21 |
| -The default structure includes the following files: |
22 |
| - |
23 |
| -- `README.md`: A description of the module |
24 |
| -- `main.tf`: The logic for the module |
25 |
| -- `version.tf`: The required terraform and provider versions |
26 |
| -- `variables.tf`: The input variables for the module |
27 |
| -- `outputs.tf`: The values that are output from the module |
28 |
| -For more information, see [Module structure](https://terraform-ibm-modules.github.io/documentation/#/module-structure) in the project documentation. |
29 |
| - |
30 |
| -You can add other content to support what your module does and how it works. For example, you might add a `scripts/` directory that contains shell scripts that are run by a `local-exec` `null_resource` in the Terraform module. |
31 |
| - |
32 |
| -Follow this process to create and submit a Terraform module. |
33 |
| - |
34 |
| -### Create a repo from this repo template |
35 |
| - |
36 |
| -1. Create a repository from this repository template by clicking `Use this template` in the upper right of the GitHub UI. |
37 |
| -    <br>For more information about creating a repository from a template, see the [GitHub docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template). |
38 |
| -1. Select `terraform-ibm-modules` as the owner. |
39 |
| -1. Enter a name for the module in format `terraform-ibm-<NAME>`, where `<NAME>` reflects the type of infrastructure that the module manages. |
40 |
| -    <br>Use hyphens as delimiters for names with multiple words (for example, terraform-ibm-`activity-tracker`). |
41 |
| -1. Provide a short description of the module. |
42 |
| -    <br>The description is displayed under the repository name on the [organization page](https://github.com/terraform-ibm-modules) and in the **About** section of the repository. Use the description to help users understand the purpose of your module. For more information, see [module names and descriptions](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions) in the docs. |
43 |
| - |
44 |
| -### Clone the repo and set up your development environment |
45 |
| - |
46 |
| -Locally clone the new repository and set up your development environment by completing the tasks in [Local development setup](https://terraform-ibm-modules.github.io/documentation/#/local-dev-setup) in the project documentation. |
47 |
| - |
48 |
| -### Update the repo name and description in source control |
49 |
| - |
50 |
| -To help make sure that the repo name and description are not changed except through pull requests, they are defined in the `settings.yml` file. |
51 |
| - |
52 |
| -Check to make sure that values are uncommented and correct: |
53 |
| - |
54 |
| -1. Open the [settings.yml](.github/settings.yml) file. |
55 |
| -1. If not already updated, uncomment the `name` and `description` properties and set the values to what you specified when you requested the repo. |
56 |
| - |
57 |
| -### Update the Terraform files |
58 |
| - |
59 |
| -Implement the logic for your module by updating the `main.tf`, `version.tf`, `variables.tf`, and `outputs.tf` Terraform files. For more information, see [Creating Terraform on IBM Cloud templates](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-create-tf-config). |
60 |
| - |
61 |
| -### Create examples and tests |
62 |
| - |
63 |
| -Add one or more examples in the `examples` directory that consume your new module, and configure tests for them in the `tests` directory. For more information about tests, see [Tests](https://terraform-ibm-modules.github.io/documentation/#/tests). |
64 |
| - |
65 |
| -### Update the content in the readme file |
66 |
| - |
67 |
| -After you implement the logic for your module and create examples and tests, update this readme file in your repository by following these steps: |
68 |
| - |
69 |
| -1. Update the title heading and add a description about your module. |
70 |
| -1. Update the badge links. |
71 |
| -1. Remove all the content in this H2 heading section. |
72 |
| -1. Complete the [Usage](#usage) and [Required IAM access policies](#required-iam-access-policies) sections. The [Examples](#examples) and [Requirements](#requirements) section are populated by a pre-commit hook. |
73 |
| - |
74 |
| -### Commit your code and submit your module for review |
75 |
| - |
76 |
| -1. Before you commit any code, review [Contributing to the IBM Cloud Terraform modules project](https://terraform-ibm-modules.github.io/documentation/#/contribute-module) in the project documentation. |
77 |
| -1. Create a pull request for review. |
78 |
| - |
79 |
| -### Post-merge steps |
80 |
| - |
81 |
| -After the first PR for your module is merged, follow these post-merge steps: |
82 |
| - |
83 |
| -1. Create a PR to enable the upgrade test by removing the `t.Skip` line in `tests/pr_test.go`. |
84 |
| - |
85 |
| -<!-- Remove the content in this previous H2 heading --> |
86 | 13 |
|
87 | 14 | ## Usage
|
88 | 15 |
|
89 |
| -<!-- |
90 |
| -Add an example of the use of the module in the following code block. |
91 |
| -
|
92 |
| -Use real values instead of "var.<var_name>" or other placeholder values |
93 |
| -unless real values don't help users know what to change. |
94 |
| ---> |
| 16 | +> WARNING: **This module does not support major version upgrade or updates to encryption and backup encryption keys**: To upgrade version create a new postgresql instance with the updated version and follow the [Upgrading PostgreSQL docs](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-upgrading&interface=cli) |
95 | 17 |
|
96 | 18 | ```hcl
|
97 |
| -
|
| 19 | +module "postgresql_db" { |
| 20 | + # replace main with version |
| 21 | + source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-icd-postgresql?ref=main" |
| 22 | + admin_password = var.admin_password |
| 23 | + resource_group_id = module.resource_group.resource_group_id |
| 24 | + name = var.name |
| 25 | +} |
98 | 26 | ```
|
99 | 27 |
|
100 | 28 | ## Required IAM access policies
|
101 | 29 |
|
102 |
| -<!-- PERMISSIONS REQUIRED TO RUN MODULE |
103 |
| -If this module requires permissions, uncomment the following block and update |
104 |
| -the sample permissions, following the format. |
105 |
| -Replace the sample Account and IBM Cloud service names and roles with the |
106 |
| -information in the console at |
107 |
| -Manage > Access (IAM) > Access groups > Access policies. |
108 |
| ---> |
109 |
| - |
110 |
| -<!-- |
111 | 30 | You need the following permissions to run this module.
|
112 | 31 |
|
113 | 32 | - Account Management
|
114 |
| - - **Sample Account Service** service |
115 |
| - - `Editor` platform access |
116 |
| - - `Manager` service access |
117 |
| - - IAM Services |
118 |
| - - **Sample Cloud Service** service |
119 |
| - - `Administrator` platform access |
120 |
| ---> |
121 |
| - |
122 |
| -<!-- NO PERMISSIONS FOR MODULE |
123 |
| -If no permissions are required for the module, uncomment the following |
124 |
| -statement instead the previous block. |
125 |
| ---> |
126 |
| - |
127 |
| -<!-- No permissions are needed to run this module.--> |
| 33 | + - **Databases for PostgreSQL** service |
| 34 | + - `Editor` role access |
128 | 35 | <!-- END MODULE HOOK -->
|
129 | 36 | <!-- BEGIN EXAMPLES HOOK -->
|
130 | 37 | ## Examples
|
131 | 38 |
|
| 39 | +- [ Autoscale example](examples/autoscale) |
| 40 | +- [ Complete example with byok encryption, CBR rules and storing credentials in secrets manager](examples/complete) |
132 | 41 | - [ Default example](examples/default)
|
133 |
| -- [ Example that uses existing resources](examples/existing-resources) |
134 |
| -- [ Non default example](examples/non-default) |
135 | 42 | <!-- END EXAMPLES HOOK -->
|
136 | 43 | <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
137 | 44 | ## Requirements
|
138 | 45 |
|
139 | 46 | | Name | Version |
|
140 | 47 | |------|---------|
|
141 |
| -| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 | |
| 48 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 | |
| 49 | +| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.49.0 | |
142 | 50 |
|
143 | 51 | ## Modules
|
144 | 52 |
|
145 |
| -No modules. |
| 53 | +| Name | Source | Version | |
| 54 | +|------|--------|---------| |
| 55 | +| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | git::https://github.com/terraform-ibm-modules/terraform-ibm-cbr//cbr-rule-module | v1.1.2 | |
146 | 56 |
|
147 | 57 | ## Resources
|
148 | 58 |
|
149 |
| -No resources. |
| 59 | +| Name | Type | |
| 60 | +|------|------| |
| 61 | +| [ibm_database.postgresql_db](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database) | resource | |
150 | 62 |
|
151 | 63 | ## Inputs
|
152 | 64 |
|
153 |
| -No inputs. |
| 65 | +| Name | Description | Type | Default | Required | |
| 66 | +|------|-------------|------|---------|:--------:| |
| 67 | +| <a name="input_allowlist"></a> [allowlist](#input\_allowlist) | Set of IP address and description to allowlist in database | <pre>list(object({<br> address = optional(string)<br> description = optional(string)<br> }))</pre> | `[]` | no | |
| 68 | +| <a name="input_auto_scaling"></a> [auto\_scaling](#input\_auto\_scaling) | (Optional) Configure rules to allow your database to automatically increase its resources. Single block of autoscaling is allowed at once. | <pre>object({<br> cpu = object({<br> rate_increase_percent = optional(number)<br> rate_limit_count_per_member = optional(number)<br> rate_period_seconds = optional(number)<br> rate_units = optional(string)<br> })<br> disk = object({<br> capacity_enabled = optional(bool)<br> free_space_less_than_percent = optional(number)<br> io_above_percent = optional(number)<br> io_enabled = optional(bool)<br> io_over_period = optional(string)<br> rate_increase_percent = optional(number)<br> rate_limit_mb_per_member = optional(number)<br> rate_period_seconds = optional(number)<br> rate_units = optional(string)<br> })<br> memory = object({<br> io_above_percent = optional(number)<br> io_enabled = optional(bool)<br> io_over_period = optional(string)<br> rate_increase_percent = optional(number)<br> rate_limit_mb_per_member = optional(number)<br> rate_period_seconds = optional(number)<br> rate_units = optional(string)<br> })<br> })</pre> | <pre>{<br> "cpu": {},<br> "disk": {},<br> "memory": {}<br>}</pre> | no | |
| 69 | +| <a name="input_backup_encryption_key_crn"></a> [backup\_encryption\_key\_crn](#input\_backup\_encryption\_key\_crn) | (Optional) The CRN of a key protect key, that you want to use for encrypting disk that holds deployment backups. If null, will use 'key\_protect\_key\_crn' as encryption key. If 'key\_protect\_key\_crn' is also null database is encrypted by using randomly generated keys. | `string` | `null` | no | |
| 70 | +| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create, if operations is not set it will default to api-type:data-plane | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> tags = optional(list(object({<br> name = string<br> value = string<br> })))<br> operations = optional(list(object({<br> api_types = list(object({<br> api_type_id = string<br> }))<br> })))<br> }))</pre> | `[]` | no | |
| 71 | +| <a name="input_configuration"></a> [configuration](#input\_configuration) | (Optional, Json String) Database Configuration in JSON format. | <pre>object({<br> max_connections = optional(number)<br> max_prepared_transactions = optional(number)<br> deadlock_timeout = optional(number)<br> effective_io_concurrency = optional(number)<br> max_replication_slots = optional(number)<br> max_wal_senders = optional(number)<br> shared_buffers = optional(number)<br> synchronous_commit = optional(string)<br> wal_level = optional(string)<br> archive_timeout = optional(number)<br> log_min_duration_statement = optional(number)<br> })</pre> | `null` | no | |
| 72 | +| <a name="input_key_protect_key_crn"></a> [key\_protect\_key\_crn](#input\_key\_protect\_key\_crn) | (Optional) The root key CRN of a Key Management Service like Key Protect or Hyper Protect Crypto Service (HPCS) that you want to use for disk encryption. If `null`, database is encrypted by using randomly generated keys. See https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok for current list of supported regions for BYOK | `string` | `null` | no | |
| 73 | +| <a name="input_member_cpu_count"></a> [member\_cpu\_count](#input\_member\_cpu\_count) | CPU allocation required for postgresql database | `string` | `"3"` | no | |
| 74 | +| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Disk allocation required for postgresql database | `string` | `"5120"` | no | |
| 75 | +| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Memory allocation required for postgresql database | `string` | `"1024"` | no | |
| 76 | +| <a name="input_members"></a> [members](#input\_members) | Number of members | `number` | `3` | no | |
| 77 | +| <a name="input_name"></a> [name](#input\_name) | Name of the Postgresql instance | `string` | n/a | yes | |
| 78 | +| <a name="input_pg_version"></a> [pg\_version](#input\_pg\_version) | Version of the postgresql instance | `string` | `null` | no | |
| 79 | +| <a name="input_plan_validation"></a> [plan\_validation](#input\_plan\_validation) | Enable or disable validating the database parameters for postgres during the plan phase | `bool` | `true` | no | |
| 80 | +| <a name="input_region"></a> [region](#input\_region) | The region postgresql is to be created on. The region must support BYOK if key\_protect\_key\_crn is used | `string` | `"us-south"` | no | |
| 81 | +| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the postgresql will be created | `string` | n/a | yes | |
| 82 | +| <a name="input_resource_tags"></a> [resource\_tags](#input\_resource\_tags) | Optional list of tags to be added to created resources | `list(string)` | `[]` | no | |
| 83 | +| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | Sets the endpoint of the Postgresql instance, valid values are 'public', 'private', or 'public-and-private' | `string` | `"private"` | no | |
154 | 84 |
|
155 | 85 | ## Outputs
|
156 | 86 |
|
157 |
| -No outputs. |
| 87 | +| Name | Description | |
| 88 | +|------|-------------| |
| 89 | +| <a name="output_id"></a> [id](#output\_id) | Postgresl instance id | |
| 90 | +| <a name="output_version"></a> [version](#output\_version) | Postgresql instance version | |
158 | 91 | <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
159 | 92 | <!-- BEGIN CONTRIBUTING HOOK -->
|
160 | 93 |
|
|
0 commit comments