Skip to content

Commit 5ce7f1e

Browse files
MrWolongxiaozhu36
authored andcommitted
Improves the module examples/complete
1 parent d719b33 commit 5ce7f1e

File tree

14 files changed

+101
-107
lines changed

14 files changed

+101
-107
lines changed

.gitignore

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
# Local .terraform directories
2-
**/.terraform/*
3-
4-
# .tfstate files
1+
# Compiled files
52
*.tfstate
6-
*.tfstate.*
7-
8-
# Crash log files
9-
crash.log
3+
*.tfstate.backup
4+
*.terraform.*
105

11-
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
12-
# .tfvars files are managed as part of configuration and so should be included in
13-
# version control.
14-
#
15-
# example.tfvars
6+
# Module directory
7+
.terraform/
168

17-
# Ignore override files as they are usually used to override resources locally and so
18-
# are not checked in
19-
override.tf
20-
override.tf.json
21-
*_override.tf
22-
*_override.tf.json
9+
# terraform log
10+
*.log
2311

24-
# Include override files you do wish to add to version control using negated pattern
25-
#
26-
# !example_override.tf
12+
# auto-generated key pair file
13+
*.pem
2714

28-
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
29-
# example: *tfplan*
15+
# tools files
16+
.DS_Store
3017
.idea
18+
19+
# others
20+
*.bak
21+
*.bk
22+
**/.terraform/*
23+
.terraform.lock.hcl
24+
.terraform.tfstate.lock.info

README-CN.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Terraform module which creates ADB cluster resources on Alibaba Cloud
22
terraform-alicloud-analyticdb-mysql
33

4-
5-
64
本 Module 用于在阿里云的 VPC 下创建一个[ADB 云数据库](https://help.aliyun.com/product/92664.html)
75

86
本 Module 支持创建以下资源:
@@ -38,7 +36,7 @@ module "adb" {
3836
* [ADB实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-analyticdb-mysql/tree/master/examples/complete)
3937

4038
## 注意事项
41-
本Module从版本v1.1.0开始已经移除掉如下的 provider 的显示设置
39+
本Module从版本v1.1.0开始已经移除掉如下的 provider 的显式设置
4240

4341
```hcl
4442
provider "alicloud" {
@@ -64,7 +62,7 @@ module "adb" {
6462
}
6563
```
6664

67-
如果你想对正在使用中的Module升级到 1.1.0 或者更高的版本,那么你可以在模板中显示定义一个相同Region的provider
65+
如果你想对正在使用中的Module升级到 1.1.0 或者更高的版本,那么你可以在模板中显式定义一个相同Region的provider
6866
```hcl
6967
provider "alicloud" {
7068
region = "cn-shenzhen"
@@ -77,7 +75,7 @@ module "adb" {
7775
// ...
7876
}
7977
```
80-
或者,如果你是多Region部署,你可以利用 `alias` 定义多个 provider,并在Module中显示指定这个provider
78+
或者,如果你是多Region部署,你可以利用 `alias` 定义多个 provider,并在Module中显式指定这个provider
8179

8280
```hcl
8381
provider "alicloud" {
@@ -104,7 +102,7 @@ module "adb" {
104102

105103
| Name | Version |
106104
|------|---------|
107-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
105+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
108106
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.71.0 |
109107

110108
提交问题
@@ -125,6 +123,4 @@ Apache 2 Licensed. See LICENSE for full details.
125123
---------
126124
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
127125
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
128-
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)
129-
130-
126+
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Terraform module which creates a ADB cluster on Alibaba Cloud.
22
terraform-alicloud-analyticdb-mysql
33

4-
54
English | [简体中文](https://github.com/terraform-alicloud-modules/terraform-alicloud-analyticdb-mysql/blob/master/README-CN.md)
65

76
Terraform module which creates ADB cluster resources on Alibaba Cloud
@@ -109,7 +108,7 @@ More details see [How to use provider in the module](https://www.terraform.io/do
109108

110109
| Name | Version |
111110
|------|---------|
112-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
111+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
113112
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.71.0 |
114113

115114
Submit Issues
@@ -130,4 +129,4 @@ Reference
130129
---------
131130
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
132131
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
133-
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)
132+
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)

examples/complete/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Complete ADB example
1+
# Complete
22

3-
Configuration in this directory creates set of ADB resources including ADB cluster
3+
Configuration in this directory creates a ADB cluster.
44

55
## Usage
66

@@ -14,3 +14,19 @@ $ terraform apply
1414

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

17+
This example provides the tf variables file in the folder `tfvars`. If you want to create or update this example,
18+
you can run this example as the following commands:
19+
```bash
20+
$ terraform plan -var-file=tfvars/01-update.tfvars
21+
$ terraform apply -var-file=tfvars/01-update.tfvars
22+
```
23+
24+
Also, you can add more variables files in the folder `tfvars`.
25+
26+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
27+
## Requirements
28+
29+
| Name | Version |
30+
|------|---------|
31+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
32+
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.71.0 |

examples/complete/main.tf

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
1-
variable "region" {
2-
default = "cn-shenzhen"
3-
}
4-
5-
variable "profile" {
6-
default = "default"
7-
}
8-
9-
provider "alicloud" {
10-
region = var.region
11-
profile = var.profile
12-
}
13-
14-
data "alicloud_zones" "default" {
15-
available_resource_creation = "ADB"
16-
enable_details = true
17-
}
18-
191
data "alicloud_vpcs" "default" {
20-
is_default = true
2+
name_regex = "default-NODELETING"
213
}
224

235
data "alicloud_vswitches" "default" {
24-
vpc_id = data.alicloud_vpcs.default.ids.0
25-
zone_id = data.alicloud_zones.default.zones.0.id
6+
name_regex = "default-zone-g"
7+
vpc_id = data.alicloud_vpcs.default.vpcs.0.id
268
}
279

2810
module "adb_example" {
29-
source = "../.."
30-
region = var.region
31-
description = "tf-module-adb-cluster-example"
11+
source = "../.."
12+
13+
create_cluster = true
14+
15+
vswitch_id = data.alicloud_vswitches.default.vswitches.0.id
16+
availability_zone = data.alicloud_vswitches.default.vswitches.0.zone_id
3217
db_cluster_version = "3.0"
3318
db_cluster_category = "Cluster"
3419
db_node_class = "C8"
3520
db_node_count = 2
36-
db_node_storage = 200
37-
pay_type = "PostPaid"
21+
db_node_storage = var.db_node_storage
3822
mode = "reserver"
39-
vswitch_id = data.alicloud_vswitches.default.ids.0
40-
availability_zone = data.alicloud_zones.default.zones.0.id
23+
pay_type = "PostPaid"
24+
description = var.description
25+
4126
}

examples/complete/output.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#################
21
# ADB Cluster
3-
#################
42
output "this_adb_cluster_id" {
53
description = "The ID of the ADB cluster."
64
value = module.adb_example.this_adb_cluster_id
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
db_node_storage = 200
2+
description = "update-tf-testacc-description"

examples/complete/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ADB Cluster
2+
variable "db_node_storage" {
3+
description = "cluster node disk storage size, unit: GB. [100-1000]. all storage size = db_node_count * db_node_storage(2 * 100 = 200GB)."
4+
type = number
5+
default = 100
6+
}
7+
8+
variable "description" {
9+
description = "Display name of the cluster, [2, 128] English or Chinese characters, must start with a letter or Chinese in size, can contain numbers, '_' or '.', '-'."
10+
type = string
11+
default = "tf-testacc-description"
12+
}

examples/complete/versions.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
terraform {
3-
required_version = ">= 0.12"
4-
}
2+
required_version = ">= 0.13"
3+
}

locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
locals {
22
# Get ID of ADB cluster
33
this_cluster_id = var.existing_cluster_id != "" ? var.existing_cluster_id : concat(alicloud_adb_cluster.this.*.id, [""])[0]
4-
}
4+
}

0 commit comments

Comments
 (0)