|
1 | | -# terraform-provider-rds-postgres |
2 | | -Terraform module which create a PostgreSQL database based on Alibaba Cloud RDS Service. |
| 1 | +Terraform module which create a PostgreSQL database based on Alibaba Cloud RDS Service. |
| 2 | + terraform-provider-rds-postgres |
| 3 | + ------------ |
| 4 | + |
| 5 | +English | [简体中文](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/blob/master/README-CN.md) |
| 6 | + |
| 7 | +Terraform module which creates rds-postgres database and sets CMS alarm for it on Alibaba Cloud. |
| 8 | + |
| 9 | +These types of resources are supported: |
| 10 | + |
| 11 | +* [Alicloud_db_instance](https://www.terraform.io/docs/providers/alicloud/r/db_instance.html) |
| 12 | +* [Alicloud_db_account](https://www.terraform.io/docs/providers/alicloud/r/db_account.html) |
| 13 | +* [Alicloud_db_database](https://www.terraform.io/docs/providers/alicloud/r/db_database.html) |
| 14 | +* [Alicloud_db_backup_policy](https://www.terraform.io/docs/providers/alicloud/r/db_backup_policy.html) |
| 15 | +* [alicloud_cms_alarm](https://www.terraform.io/docs/providers/alicloud/r/alarm_rule.html) |
| 16 | + |
| 17 | + |
| 18 | +## Terraform versions |
| 19 | + |
| 20 | +This module requires Terraform 0.12 and Terraform Provider Alicloud 1.71.0+. |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +For new instance |
| 25 | + |
| 26 | +```hcl |
| 27 | +module "postgres" { |
| 28 | + source = "terraform-alicloud-modules/rds-postgres/alicloud" |
| 29 | + region = "cn-hangzhou" |
| 30 | +
|
| 31 | + ################# |
| 32 | + # Rds Instance |
| 33 | + ################# |
| 34 | + engine_version = "10.0" |
| 35 | + instance_storage = 20 |
| 36 | + instance_charge_type = "Postpaid" |
| 37 | + vswitch_id = "vsw-bp1tili2u5kxxxxxx" |
| 38 | + instance_name = "PostgreSQLInstance" |
| 39 | + instance_type = "rds.pg.s1.small" |
| 40 | + security_group_ids = ["sg-2ze7v4p5skehxxxxxxxx"] |
| 41 | + security_ips = ["11.193.xx.xx/24", "101.37.xx.xx/24"] |
| 42 | + tags = { |
| 43 | + Env = "Private" |
| 44 | + Location = "Secret" |
| 45 | + } |
| 46 | +
|
| 47 | + #################### |
| 48 | + # Rds Backup policy |
| 49 | + #################### |
| 50 | + preferred_backup_period = ["Monday", "Wednesday"] |
| 51 | + preferred_backup_time = "00:00Z-01:00Z" |
| 52 | + backup_retention_period = 7 |
| 53 | + log_backup_retention_period = 7 |
| 54 | + enable_backup_log = true |
| 55 | + allocate_public_connection = false |
| 56 | +
|
| 57 | + ########### |
| 58 | + #databases |
| 59 | + ########### |
| 60 | + privilege = "ReadOnly" |
| 61 | + databases = [ |
| 62 | + { |
| 63 | + name = "dbuser1" |
| 64 | + character_set = "UTF8" |
| 65 | + description = "db1" |
| 66 | + }, |
| 67 | + { |
| 68 | + name = "dbuser2" |
| 69 | + character_set = "UTF8" |
| 70 | + description = "db2" |
| 71 | + }, |
| 72 | + ] |
| 73 | +
|
| 74 | + ####################### |
| 75 | + # Rds Database account |
| 76 | + ####################### |
| 77 | + account_privilege = "DBOwner" |
| 78 | + account_name = "account_name1" |
| 79 | + account_password = "yourpassword123" |
| 80 | +
|
| 81 | + ############# |
| 82 | + # Alarm Rule |
| 83 | + ############# |
| 84 | + alarm_rule_name = "CmsAlarmForPostgreSQL" |
| 85 | + alarm_rule_statistics = "Average" |
| 86 | + alarm_rule_period = 300 |
| 87 | + alarm_rule_operator = "<=" |
| 88 | + alarm_rule_threshold = 35 |
| 89 | + alarm_rule_triggered_count = 2 |
| 90 | + alarm_rule_contact_groups = ["postgre"] |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +For existing instance |
| 95 | +```hcl |
| 96 | +module "postgres" { |
| 97 | + source = "terraform-alicloud-modules/rds-postgres/alicloud" |
| 98 | + region = "cn-beijing" |
| 99 | +
|
| 100 | + ################# |
| 101 | + # Rds Instance |
| 102 | + ################# |
| 103 | + existing_instance_id = "pgm-2zehbutrxxxxxx" |
| 104 | +
|
| 105 | + ################# |
| 106 | + # Rds Backup policy |
| 107 | + ################# |
| 108 | + create_backup_policy=true |
| 109 | + preferred_backup_period = ["Monday", "Wednesday"] |
| 110 | + preferred_backup_time = "00:00Z-01:00Z" |
| 111 | + backup_retention_period = 7 |
| 112 | + log_backup_retention_period = 7 |
| 113 | + enable_backup_log = true |
| 114 | + allocate_public_connection = false |
| 115 | +
|
| 116 | + ########### |
| 117 | + #databases |
| 118 | + ########### |
| 119 | + databases = [ |
| 120 | + { |
| 121 | + name = "postgre_sqldb" |
| 122 | + character_set = "UTF8" |
| 123 | + description = "db1" |
| 124 | + } |
| 125 | + ] |
| 126 | +
|
| 127 | + ####################### |
| 128 | + # Rds Database Account |
| 129 | + ####################### |
| 130 | + account_privilege = "DBOwner" |
| 131 | + account_name = "account_name" |
| 132 | + account_password = "yourpassword123" |
| 133 | + tags = { |
| 134 | + Env = "Private" |
| 135 | + Location = "Secret" |
| 136 | + } |
| 137 | +
|
| 138 | + ############# |
| 139 | + # Alarm Rule |
| 140 | + ############# |
| 141 | + alarm_rule_name = "CmsAlarmForPostgreSQL" |
| 142 | + alarm_rule_statistics = "Average" |
| 143 | + alarm_rule_period = 300 |
| 144 | + alarm_rule_operator = "<=" |
| 145 | + alarm_rule_threshold = 35 |
| 146 | + alarm_rule_triggered_count = 2 |
| 147 | + alarm_rule_contact_groups = ["postgre"] |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | + |
| 152 | +## Examples |
| 153 | + |
| 154 | +* [Complete Example](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/examples/complete) |
| 155 | +* [Using exising Rds Instance Example](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/examples/using-existing-rds-instance) |
| 156 | + |
| 157 | +## Modules |
| 158 | + |
| 159 | +* [database](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/database) |
| 160 | +* [postgres-10-basic](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-10-basic) |
| 161 | +* [postgres-10-high-availability](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-10-high-availability) |
| 162 | +* [postgres-11-basic](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-11-basic) |
| 163 | +* [postgres-11-high-availability](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-11-high-availability) |
| 164 | +* [postgres-12-basic](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-12-basic) |
| 165 | + |
| 166 | +## Notes |
| 167 | + |
| 168 | +* This module using AccessKey and SecretKey are from 'profile' and 'shared_credentials_file'. |
| 169 | +If you have not set them yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it. |
| 170 | + |
| 171 | +Authors |
| 172 | +------- |
| 173 | +Created and maintained by He Guimin(@xiaozhu36, heguimin36@163.com) and Yi Jincheng(yi785301535@163.com) |
| 174 | + |
| 175 | +License |
| 176 | +---- |
| 177 | +Apache 2 Licensed. See LICENSE for full details. |
| 178 | + |
| 179 | +Reference |
| 180 | +--------- |
| 181 | +* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud) |
| 182 | +* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/) |
| 183 | +* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html) |
| 184 | + |
0 commit comments