Skip to content

Commit 7e7664d

Browse files
Rich-yixiaozhu36
authored andcommitted
Supplement field descriptions to improve readme
1 parent 029236b commit 7e7664d

33 files changed

+1351
-142
lines changed

README-CN.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Terraform module which creates MongoDB instance resources on Alibaba Cloud
2+
3+
terraform-alicloud-mongodb
4+
=====================================================================
5+
6+
7+
本 Module 用于在阿里云的 VPC 下创建一个[MongoDB云数据库](https://help.aliyun.com/document_detail/26558.html).
8+
9+
本 Module 支持创建以下资源:
10+
11+
* [MongoDB 数据库实例_(mongodb_instance)](https://www.terraform.io/docs/providers/alicloud/r/mongodb_instance.html)
12+
13+
## Terraform 版本
14+
15+
本模板要求使用版本 Terraform 0.12。
16+
17+
## 用法
18+
19+
```hcl
20+
module "mongodb" {
21+
source = "terraform-alicloud-modules/mongodb/alicloud"
22+
region = "cn-shanghai"
23+
#################
24+
# MongoDB Instance
25+
#################
26+
replication_factor = 3
27+
name = "my-mongo"
28+
instance_charge_type = "PostPaid"
29+
db_instance_class = "dds.mongo.mid"
30+
db_instance_storage = 10
31+
period = 1
32+
security_ip_list = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
33+
vswitch_id = "vsw-uf6ocf31lyoqvw2jmmr9f"
34+
zone_id = "cn-shanghai-b"
35+
account_password = "mongo123"
36+
backup_period = ["Monday", "Wednesday", "Friday"]
37+
backup_time = "02:00Z-03:00Z"
38+
tags = {
39+
Env = "Private"
40+
Location = "Secret"
41+
}
42+
}
43+
```
44+
45+
## 示例
46+
47+
* [MongoDB 实例完整创建示例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-mongodb/tree/master/examples/mongodb)
48+
49+
## 模块
50+
51+
* [mongodb-3.4-rocksdb](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-3.4-rocksdb)
52+
* [mongodb-3.4-wiredtiger](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-3.4-wiredtiger)
53+
* [mongodb-4.0-wiredtiger](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-4.0-wiredtiger)
54+
* [mongodb-4.2-wiredtiger](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-4.2-wiredtiger)
55+
56+
57+
## 注意事项
58+
59+
* 本 Module 使用的 AccessKey 和 SecretKey 可以直接从 `profile``shared_credentials_file` 中获取。如果未设置,可通过下载安装 [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) 后进行配置.
60+
61+
作者
62+
-------
63+
Created and maintained by Yi Jincheng(yi785301535@163.com)
64+
65+
许可
66+
----
67+
Apache 2 Licensed. See LICENSE for full details.
68+
69+
参考
70+
---------
71+
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
72+
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
73+
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)
74+
75+

README.md

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,81 @@
1-
# terraform-alicloud-mongodb
2-
31
Terraform module which creates MongoDB instance on Alibaba Cloud
42

5-
## mongodb replica instance
3+
terraform-alicloud-mongodb
4+
=====================================================================
5+
6+
English | [简体中文](https://github.com/terraform-alicloud-modules/terraform-alicloud-mongodb/blob/master/README-cn.md)
67

78
Terraform module which creates MongoDB replica instance resources on Alibaba Cloud
89

910
These types of resources are supported:
1011

11-
- [mongodb_instance] (https://www.terraform.io/docs/providers/alicloud/r/mongodb_instance.html)
12+
* [Alicloud_mongodb_instance](https://www.terraform.io/docs/providers/alicloud/r/mongodb_instance.html)
1213

13-
## Usage
14+
----------------------
15+
16+
## Terraform versions
1417

18+
This module requires Terraform 0.12.
19+
20+
## Usage
21+
-----
1522
You can use this in your terraform template with the following steps.
1623

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

19-
```tf
20-
module "mongodb_instance" {
26+
```hcl
27+
module "mongodb" {
2128
source = "terraform-alicloud-modules/mongodb/alicloud"
22-
engine_version = "${var.engine_version}"
23-
db_instance_class = "${var.db_instance_class}"
24-
db_instance_storage = "${var.db_instance_storage}"
25-
name = "${var.name}"
26-
instance_charge_type = "${var.instance_charge_type}"
27-
vswitch_id = "${var.vswitch_id}"
28-
security_ip_list = "${var.security_ip_list}"
29+
region = "cn-shanghai"
30+
#################
31+
# MongoDB Instance
32+
#################
33+
replication_factor = 3
34+
name = "my-mongo"
35+
instance_charge_type = "PostPaid"
36+
db_instance_class = "dds.mongo.mid"
37+
db_instance_storage = 10
38+
period = 1
39+
security_ip_list = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
40+
vswitch_id = "vsw-uf6ocf31lyoqvw2jmmr9f"
41+
zone_id = "cn-shanghai-b"
42+
account_password = "mongo123"
43+
backup_period = ["Monday", "Wednesday", "Friday"]
44+
backup_time = "02:00Z-03:00Z"
45+
tags = {
46+
Env = "Private"
47+
Location = "Secret"
48+
}
2949
}
3050
```
3151

32-
1. Setting `access_key` and `secret_key` values through environment variables:
33-
34-
- ALICLOUD_ACCESS_KEY
35-
- ALICLOUD_SECRET_KEY
36-
- ALICLOUD_REGION
37-
38-
## Input
39-
40-
| Name | Description | Type | Default | Required |
41-
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | :--------: | :------: |
42-
| engine_version | Database version. Value options:3.4 3.6 4.0 | string | "" | yes |
43-
| instance_type | DB Instance type. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/57141.htm). | string | "" | yes |
44-
| instance_storage | User-defined DB instance storage space. Value range:[10,2000] Increase progressively at a rate of 5 GB. For details, see [Instance type table](https://www.alibabacloud.com/help/doc-detail/26312.htm). | string | 10 | yes |
45-
| instance_name | The name of DB instance. It a string of 2 to 256 characters. | string | "" | no |
46-
| instance_charge_type | Valid values are PrePaid, PostPaid, Default to PostPaid. | string | PostPaid | no | "PostPaid" |
47-
| 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 | "" | no |
48-
| vswitch_id | VSwitch ID. If the instance type is VPC, this parameter cannot be left blank. | string | "" | no |
49-
| security_ip_list | 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 |
50-
| vswitch_id | VSwitch ID. If the instance type is VPC, this parameter cannot be left blank. | string | "" | no |
51-
| storage_engine | Storage engine; optional values: WiredTiger or RocksDB. | string | WiredTiger | no |
52-
| replication_factor | Number of replica set nodes. Valid values: [3,5,7] | int | 3 | no |
53-
| account_password | Password of the root account | string | "" | no |
54-
55-
## Outputs
56-
57-
| Name | Description |
58-
| ----------------------------- | -------------------------------- |
59-
| this_db_instance_id | instance ID created |
60-
| this_db_instance_name | instance name configured |
61-
| this_db_instance_security_ips | instance security ips configured |
62-
| this_db_instance_zone_id | instance zone ID created |
63-
| this_db_instance_vswitch_id | instance vswitch ID created |
52+
## Examples
53+
54+
* [MongoDB example](https://github.com/terraform-alicloud-modules/terraform-alicloud-mongodb/tree/master/examples/mongodb)
55+
56+
## Module
57+
58+
* [mongodb-3.4-rocksdb](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-3.4-rocksdb)
59+
* [mongodb-3.4-wiredtiger](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-3.4-wiredtiger)
60+
* [mongodb-4.0-wiredtiger](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-4.0-wiredtiger)
61+
* [mongodb-4.2-wiredtiger](https://github.com/terraform-alicloud-mongodb/tree/mongodb/modules/mongodb-4.2-wiredtiger)
62+
63+
## Notes
64+
65+
* This module using AccessKey and SecretKey are from `profile` and `shared_credentials_file`.
66+
If you have not set them yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it.
67+
68+
69+
Authors
70+
---------
71+
Created and maintained by Yi Jincheng(yi785301535@163.com)
72+
73+
License
74+
----
75+
Apache 2 Licensed. See LICENSE for full details.
76+
77+
Reference
78+
---------
79+
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
80+
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
81+
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)

examples/README.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

examples/main.tf

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/mongodb/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Complete MongoDB example
2+
3+
Configuration in this directory creates set of MongoDB resources including DB instance
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```bash
10+
$ terraform init
11+
$ terraform plan
12+
$ terraform apply
13+
```
14+
15+
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
16+

examples/mongodb/main.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
variable "region" {
2+
default = "cn-shanghai"
3+
}
4+
provider "alicloud" {
5+
region = var.region
6+
}
7+
data "alicloud_vpcs" "default" {
8+
is_default = true
9+
}
10+
data "alicloud_zones" "default" {
11+
available_resource_creation = "MongoDB"
12+
multi = true
13+
}
14+
resource "alicloud_vswitch" "this" {
15+
name = "mongodb_vpc"
16+
availability_zone = data.alicloud_zones.default.zones.0.multi_zone_ids.0
17+
vpc_id = data.alicloud_vpcs.default.vpcs.0.id
18+
cidr_block = cidrsubnet(data.alicloud_vpcs.default.vpcs.0.cidr_block, 4, 4)
19+
}
20+
module "mongodb_example" {
21+
source = "../../modules/mongodb-3.4-rocksdb"
22+
region = var.region
23+
replication_factor = 3
24+
name = "my-mongo"
25+
instance_charge_type = "PostPaid"
26+
db_instance_class = "dds.mongo.mid"
27+
db_instance_storage = 10
28+
period = 1
29+
security_ip_list = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
30+
vswitch_id = alicloud_vswitch.this.id
31+
zone_id = data.alicloud_zones.default.zones.0.multi_zone_ids.0
32+
account_password = "mongo123"
33+
backup_period = ["Monday", "Wednesday", "Friday"]
34+
backup_time = "02:00Z-03:00Z"
35+
tags = {
36+
Env = "Private"
37+
Location = "Secret"
38+
}
39+
}

examples/mongodb/output.tf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#################
2+
# MongoDB Instance
3+
#################
4+
output "this_mongodb_instance_id" {
5+
description = "The ID of the MongoDB instance. "
6+
value = module.mongodb_example.this_mongodb_instance_id
7+
}
8+
9+
output "this_mongodb_instance_engine_version" {
10+
description = "The engine version of the MongoDB instance. "
11+
value = module.mongodb_example.this_mongodb_instance_engine_version
12+
}
13+
14+
output "this_mongodb_instance_charge_type" {
15+
description = "The billing method of the instance. "
16+
value = module.mongodb_example.this_mongodb_instance_charge_type
17+
}
18+
19+
output "this_mongodb_instance_period" {
20+
description = "The duration that you will buy MongoDB instance. "
21+
value = module.mongodb_example.this_mongodb_instance_period
22+
}
23+
24+
output "this_mongodb_instance_zone_id" {
25+
description = "The Zone to launch the MongoDB instance. "
26+
value = module.mongodb_example.this_mongodb_instance_zone_id
27+
}
28+
output "this_mongodb_instance_vswitch_id" {
29+
description = "The virtual switch ID to launch MongoDB instances in one VPC. "
30+
value = module.mongodb_example.this_mongodb_instance_vswitch_id
31+
}
32+
33+
output "this_mongodb_instance_tags" {
34+
description = "A mapping of tags to assign to the MongoDB instance resource. "
35+
value = module.mongodb_example.this_mongodb_instance_tags
36+
}
37+
output "this_mongodb_instance_storage" {
38+
description = "User-defined DB instance storage space. "
39+
value = module.mongodb_example.this_mongodb_instance_storage
40+
}
41+
output "this_mongodb_instance_class" {
42+
description = "The class of MongoDB instance"
43+
value = module.mongodb_example.this_mongodb_instance_class
44+
}
45+
46+
output "this_mongodb_instance_storage_engine" {
47+
description = "The storage engine used by the MongoDB instance. "
48+
value = module.mongodb_example.this_mongodb_instance_storage_engine
49+
}
50+
output "this_mongodb_instance_name" {
51+
description = "The name of MongoDB instance. "
52+
value = module.mongodb_example.this_mongodb_instance_name
53+
}
54+
output "this_mongodb_instance_security_ip_list" {
55+
description = "IP whitelist of MongoDB instances. "
56+
value = module.mongodb_example.this_mongodb_instance_security_ip_list
57+
}
58+
59+
output "this_mongodb_instance_replication_factor" {
60+
description = "Number of replica set nodes. "
61+
value = module.mongodb_example.this_mongodb_instance_replication_factor
62+
}
63+
64+
output "this_mongodb_instance_backup_period" {
65+
description = "The MongoDB instance backup period. "
66+
value = module.mongodb_example.this_mongodb_instance_period
67+
}
68+
69+
output "this_mongodb_instance_backup_time" {
70+
description = "The MongoDB instance backup time. "
71+
value = module.mongodb_example.this_mongodb_instance_backup_time
72+
}
File renamed without changes.

0 commit comments

Comments
 (0)