Skip to content

Commit

Permalink
add readme-cn and improve modules readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-yi committed Jan 6, 2020
1 parent e09b7ea commit 29bf116
Show file tree
Hide file tree
Showing 29 changed files with 343 additions and 747 deletions.
92 changes: 92 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
terraform-alicloud-rds
=====================================================================


本 Module 用于在阿里云的 VPC 下创建一个[云服务器rds实例(rds Instance)](https://help.aliyun.com/document_detail/26092.html?spm=a2c4g.11174283.2.2.19df4c22TsZmot).

本 Module 支持创建以下资源:

* [云服务器rds实例(rds Instance)](https://www.terraform.io/docs/providers/alicloud/r/db_instance.html)

## Terraform 版本

如果您正在使用 Terraform 0.12,请使用此模块的`v2.*` and `v1.3.0` 版本。

如果您正在使用 Terraform 0.11,请使用此模块的`v1.2.*` 版本.

## 用法

```hcl
variable "region" {
default = "cn-hangzhou"
}
provider "alicloud" {
region = var.region
}
data "alicloud_vpcs" "default" {
is_default = true
}
module "mysql" {
source = "terraform-alicloud-modules/rds/alicloud/mysql-8.0-high-availability"
region = var.region
connection_prefix = "developmentabc"
vswitch_id = data.alicloud_vpcs.default.vpcs.0.vswitch_ids.0
instance_name = "myDBInstance"
security_ips = [
"11.193.54.0/24",
"101.37.74.0/24",
"10.137.42.0/24",
"121.43.18.0/24"]
preferred_backup_period = ["Monday", "Wednesday"]
preferred_backup_time = "00:00Z-01:00Z"
backup_retention_period = 7
log_backup_retention_period = 7
###########
#databases#
###########
account_name = "account_name1"
password = "1234abc"
privilege = "ReadWrite"
databases = [
{
name = "dbuserv1"
character_set = "utf8"
description = "db1"
},
{
name = "dbuserv2"
character_set = "utf8"
description = "db2"
},
]
}
```

## 示例

* [Mysql 实例完整创建示例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/mysql)
* [PostSQL 实例完整创建示例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/postgre_sql)
* [PPAS 实例完整创建示例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/ppas)
* [SQL Server 实例完整创建示例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/sql_server)

## 注意事项

* 本 Module 使用的 AccessKey 和 SecretKey 可以直接从 `profile``shared_credentials_file` 中获取。如果未设置,可通过下载安装 [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) 后进行配置.
* 本 Module 用创建 VPC 实例,`vswitch_id``vswitch_ids` 至少要设置一个。如果两个都设置了,`vswitch_id` 将会优先于 `vswitch_ids` 被使用。

作者
-------
Created and maintained by He Guimin(@xiaozhu36, heguimin36@163.com)

许可
----
Apache 2 Licensed. See LICENSE for full details.

参考
---------
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)


95 changes: 40 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
# Alibaba Cloud RDS Instance Terraform Module
Alibaba Cloud RDS Instance Terraform Module
terraform-alicloud-rds
---
=====================================================================

This Terraform module will first creates a RDS instance, then create and associate a database and DB account to this instance.
Also you can config the backup policy of instance created on Alibaba Cloud.
English | [简体中文](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/blob/master/README-CN.md)

Terraform module which creates rds instance(s) on Alibaba Cloud.

These types of resources are supported:

* [Alicloud_db_instance](https://www.terraform.io/docs/providers/alicloud/r/db_instance.html)
* [Alicloud_db_account](https://www.terraform.io/docs/providers/alicloud/r/db_account.html)
* [Alicloud_db_database](https://www.terraform.io/docs/providers/alicloud/r/db_database.html)
* [Alicloud_db_backup_policy](https://www.terraform.io/docs/providers/alicloud/r/db_backup_policy.html)
* [rds Instance](https://www.terraform.io/docs/providers/alicloud/r/db_instance.html)

## Terraform versions

----------------------
For Terraform 0.12 use version `v2.*` and `v1.3.0` of this module.

If you are using Terraform 0.11 you can use versions `v1.2.*`.

Usage
-----
You can use this in your terraform template with the following steps.
## Usage

1. Adding a module resource to your template, e.g. main.tf

```hcl
variable "region" {
default = "cn-hangzhou"
}
provider "alicloud" {
region = var.region
}
data "alicloud_vpcs" "default" {
is_default = true
}
module "mysql" {
source = "../../modules/mysql-5.7-basic"
source = "terraform-alicloud-modules/rds/alicloud//mysql-8.0-high-availability"
region = var.region
connection_prefix = "developmentabc"
vswitch_id = data.alicloud_vpcs.default.vpcs.0.vswitch_ids.0
instance_name = "myDBInstance"
instance_type = "rds.mysql.s2.large"
security_ips = [
"11.193.54.0/24",
"101.37.74.0/24",
"10.137.42.0/24",
"121.43.18.0/24"]
preferred_backup_period = ["Monday", "Wednesday"]
preferred_backup_period = ["Monday", "Wednesday"]
preferred_backup_time = "00:00Z-01:00Z"
backup_retention_period = 7
enable_backup_log = true
log_backup_retention_period = 7
###########
#databases#
Expand All @@ -59,54 +63,35 @@ module "mysql" {
},
]
}
```

2. Setting `access_key` and `secret_key` values through environment variables:
- ALICLOUD_ACCESS_KEY
- ALICLOUD_SECRET_KEY
- ALICLOUD_REGION
```

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
|engine | Database type. Value options: MySQL, SQLServer, PostgreSQL, and PPAS. | string | MySQL | yes |
|engine_version | Database version. Value options:<br>5.5/5.6/5.7 for MySQL ;<br>2008r2/2012 for SQLServer; <br>9.4/10.0 for PostgreSQL; <br>9.3 for PPAS | string | 5.7 | yes |
|instance_type | DB Instance type. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm). | string | mysql.n1.micro.1 | yes |
|instance_storage | User-defined DB instance storage space. Value range:<br>[5, 2000] for MySQL/PostgreSQL/PPAS HA dual node edition;<br>[20,1000] for MySQL 5.7 basic single node edition;<br>[10, 2000] for SQL Server 2008R2;<br>[20,2000] for SQL Server 2012 basic single node edition Increase progressively at a rate of 5 GB. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm). | string | 20 | yes |
|instance_name | The name of DB instance. It a string of 2 to 256 characters. | string | myTestDBInstance | no |
|instance_charge_type | Valid values are Prepaid, Postpaid, Default to Postpaid. | string | Postpaid | no | = "Postpaid"
|zone_id | The Zone to launch the DB instance. From version 1.8.1, it supports multiple zone. If it is a multi-zone and vswitch_id is specified, the vswitch must in the one of them. The multiple zone ID can be retrieved by setting multi to "true" in the data source alicloud_zones. | string | cn-hangzhou-b | no |
|security_ips | List of IP addresses allowed to access all databases of an instance. The list contains up to 1,000 IP addresses, separated by commas. Supported formats include 0.0.0.0/0, 10.23.12.24 (IP), and 10.23.12.24/24 (Classless Inter-Domain Routing (CIDR) mode. /24 represents the length of the prefix in an IP address. The range of the prefix length is [1,32]). | list | [] | no |

## Examples

## Outputs
* [Mysql example](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/mysql)
* [PostSQL example](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/postgre_sql)
* [PPAS example](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/ppas)
* [SQL Server example](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds/tree/master/examples/sql_server)

| Name | Description |
|------|-------------|
| this_db_instance_id | instance ID created |
| this_db_instance_engine | instance engine created |
| this_db_instance_engine_version | instance engine version created |
| this_db_instance_instance_name | instance name created |
| this_db_instance_instance_type | instance type created |
| this_db_instance_zone_id | instance zone ID created |
| this_db_instance_connection_string | intance public net connection string created |
| this_db_instance_port | instance connection port created |
| this_db_instance_security_ips | instance security ips configured |
| this_db_instance_databese_id | database ID created in this instance |
| this_db_instance_databese_name | database name created in this instance |
| this_db_instance_databese_account | database account associated in this instance |
| this_db_instance_databese_accountprivilege | database account privilege associated in this instance |
## Notes

* This module using AccessKey and SecretKey are from `profile` and `shared_credentials_file`.
If you have not set them yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it.
* One of `vswitch_id` or `vswitch_ids` is required. If both are provided, the value of `vswitch_id` is prepended to the value of `vswitch_ids`.

Authors
---------
Created and maintained by Yongjin Yan(@YongjinYan, yanyongjin@gmail.com)
-------
Created and maintained by He Guimin(@xiaozhu36, heguimin36@163.com)

License
----
Apache 2 Licensed. See LICENSE for full details.

Reference
---------
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)


27 changes: 2 additions & 25 deletions examples/mysql/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Complete RDS example for MySQL

Configuration in this directory creates set of RDS resources including DB instance, DB account and Datebase.

## Usage

To run this example you need to execute:
Expand All @@ -12,27 +10,6 @@ $ terraform plan
$ terraform apply
```

Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## Outputs

| Name | Description |
|------|-------------|
| this_db_instance_id | instance ID created |
| this_db_instance_engine | instance engine created |
| this_db_instance_engine_version | instance engine version created |
| this_db_instance_instance_name | instance name created |
| this_db_instance_instance_type | instance type created |
| this_db_instance_zone_id | instance zone ID created |
| this_db_instance_connection_string | intance public net connection string created |
| this_db_instance_port | instance connection port created |
| this_db_instance_security_ips | instance security ips configured |
| this_db_instance_database_id | database ID created in this instance |
| this_db_instance_database_name | database name created in this instance |
| this_db_instance_database_account | database account associated in this instance |
| this_db_instance_database_accountprivilege | database account privilege associated in this instance |

Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2 changes: 1 addition & 1 deletion examples/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module "mysql" {
connection_prefix = "developmentabc"
vswitch_id = data.alicloud_vpcs.default.vpcs.0.vswitch_ids.0
instance_name = "myDBInstance"
//instance_type = "rds.mysql.s2.large"

security_ips = [
"11.193.54.0/24",
"101.37.74.0/24",
Expand Down
27 changes: 2 additions & 25 deletions examples/postgre_sql/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Complete RDS example for PostgreSQL

Configuration in this directory creates set of RDS resources including DB instance, DB account and Datebase.

## Usage

To run this example you need to execute:
Expand All @@ -12,27 +10,6 @@ $ terraform plan
$ terraform apply
```

Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## Outputs

| Name | Description |
|------|-------------|
| this_db_instance_id | instance ID created |
| this_db_instance_engine | instance engine created |
| this_db_instance_engine_version | instance engine version created |
| this_db_instance_instance_name | instance name created |
| this_db_instance_instance_type | instance type created |
| this_db_instance_zone_id | instance zone ID created |
| this_db_instance_connection_string | intance public net connection string created |
| this_db_instance_port | instance connection port created |
| this_db_instance_security_ips | instance security ips configured |
| this_db_instance_database_id | database ID created in this instance |
| this_db_instance_database_name | database name created in this instance |
| this_db_instance_database_account | database account associated in this instance |
| this_db_instance_database_accountprivilege | database account privilege associated in this instance |

Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
27 changes: 2 additions & 25 deletions examples/ppas/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Complete RDS example for PPAS

Configuration in this directory creates set of RDS resources including DB instance, DB account and Datebase.

## Usage

To run this example you need to execute:
Expand All @@ -12,27 +10,6 @@ $ terraform plan
$ terraform apply
```

Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## Outputs

| Name | Description |
|------|-------------|
| this_db_instance_id | instance ID created |
| this_db_instance_engine | instance engine created |
| this_db_instance_engine_version | instance engine version created |
| this_db_instance_instance_name | instance name created |
| this_db_instance_instance_type | instance type created |
| this_db_instance_zone_id | instance zone ID created |
| this_db_instance_connection_string | intance public net connection string created |
| this_db_instance_port | instance connection port created |
| this_db_instance_security_ips | instance security ips configured |
| this_db_instance_database_id | database ID created in this instance |
| this_db_instance_database_name | database name created in this instance |
| this_db_instance_database_account | database account associated in this instance |
| this_db_instance_database_accountprivilege | database account privilege associated in this instance |

Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
27 changes: 2 additions & 25 deletions examples/sql_server/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Complete RDS example for SqlServer

Configuration in this directory creates set of RDS resources including DB instance, DB account and Datebase.

## Usage

To run this example you need to execute:
Expand All @@ -12,27 +10,6 @@ $ terraform plan
$ terraform apply
```

Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## Outputs

| Name | Description |
|------|-------------|
| this_db_instance_id | instance ID created |
| this_db_instance_engine | instance engine created |
| this_db_instance_engine_version | instance engine version created |
| this_db_instance_instance_name | instance name created |
| this_db_instance_instance_type | instance type created |
| this_db_instance_zone_id | instance zone ID created |
| this_db_instance_connection_string | intance public net connection string created |
| this_db_instance_port | instance connection port created |
| this_db_instance_security_ips | instance security ips configured |
| this_db_instance_database_id | database ID created in this instance |
| this_db_instance_database_name | database name created in this instance |
| this_db_instance_database_account | database account associated in this instance |
| this_db_instance_database_accountprivilege | database account privilege associated in this instance |

Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Loading

0 comments on commit 29bf116

Please sign in to comment.