Skip to content

Commit 4e13d85

Browse files
committed
module: support alicloud_adb_db_cluster instead of alicloud_adb_cluster
1 parent 33622d1 commit 4e13d85

File tree

5 files changed

+37
-59
lines changed

5 files changed

+37
-59
lines changed

examples/complete/main.tf

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
data "alicloud_vpcs" "default" {
2-
name_regex = "default-NODELETING"
1+
variable "name" {
2+
default = "terraform-example"
33
}
44

5+
data "alicloud_adb_zones" "default" {}
6+
7+
data "alicloud_vpcs" "default" {
8+
name_regex = "^default-NODELETING$"
9+
}
510
data "alicloud_vswitches" "default" {
6-
name_regex = "default-zone-g"
7-
vpc_id = data.alicloud_vpcs.default.vpcs.0.id
11+
vpc_id = data.alicloud_vpcs.default.ids.0
12+
zone_id = data.alicloud_adb_zones.default.ids.0
813
}
914

1015
module "adb_example" {
1116
source = "../.."
1217

13-
create_cluster = true
14-
1518
vswitch_id = data.alicloud_vswitches.default.vswitches.0.id
1619
availability_zone = data.alicloud_vswitches.default.vswitches.0.zone_id
1720
db_cluster_version = "3.0"
1821
db_cluster_category = "Cluster"
1922
db_node_class = "C8"
20-
db_node_count = 2
23+
db_node_count = 1
2124
db_node_storage = var.db_node_storage
2225
mode = "reserver"
23-
pay_type = "PostPaid"
26+
payment_type = "PayAsYouGo"
2427
description = var.description
2528

26-
}
29+
}

locals.tf

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

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resource "alicloud_adb_cluster" "this" {
1+
resource "alicloud_adb_db_cluster" "this" {
22
count = var.create_cluster ? 1 : 0
33
vswitch_id = var.vswitch_id
44
zone_id = var.availability_zone
@@ -8,6 +8,6 @@ resource "alicloud_adb_cluster" "this" {
88
db_node_count = var.db_node_count
99
db_node_storage = var.db_node_storage
1010
mode = var.mode
11-
pay_type = var.pay_type
11+
payment_type = var.payment_type
1212
description = var.description
13-
}
13+
}

outputs.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,45 @@ output "this_adb_cluster_id" {
66

77
output "this_adb_description" {
88
description = "The description of ADB cluster."
9-
value = concat(alicloud_adb_cluster.this.*.description, [""])[0]
9+
value = alicloud_adb_db_cluster.this[*].description
1010
}
1111

1212
output "this_adb_cluster_zone_id" {
1313
description = "The Zone to launch the ADB cluster."
14-
value = concat(alicloud_adb_cluster.this.*.zone_id, [""])[0]
14+
value = alicloud_adb_db_cluster.this[*].zone_id
1515
}
1616

1717
output "this_adb_cluster_vswitch_id" {
1818
description = "The virtual switch ID to launch ADB cluster in one VPC. "
19-
value = concat(alicloud_adb_cluster.this.*.vswitch_id, [""])[0]
19+
value = alicloud_adb_db_cluster.this[*].vswitch_id
2020
}
2121

2222
output "this_adb_cluster_db_cluster_version" {
2323
description = "The version of the ADB cluster."
24-
value = concat(alicloud_adb_cluster.this.*.db_cluster_version, [""])[0]
24+
value = alicloud_adb_db_cluster.this[*].db_cluster_version
2525
}
2626

2727
output "this_adb_cluster_db_cluster_category" {
2828
description = "The catrgory type of the ADB cluster. "
29-
value = concat(alicloud_adb_cluster.this.*.db_cluster_category, [""])[0]
29+
value = alicloud_adb_db_cluster.this[*].db_cluster_category
3030
}
3131

3232
output "this_adb_cluster_db_node_class" {
3333
description = "The node class of the core node. "
34-
value = concat(alicloud_adb_cluster.this.*.db_node_class, [""])[0]
34+
value = alicloud_adb_db_cluster.this[*].db_node_class
3535
}
3636

3737
output "this_adb_cluster_db_node_count" {
3838
description = "The node count of the ADB cluster. "
39-
value = concat(alicloud_adb_cluster.this.*.db_node_count, [""])[0]
39+
value = alicloud_adb_db_cluster.this[*].db_node_count
4040
}
4141

4242
output "this_adb_cluster_db_node_storage" {
4343
description = "The node storage size of the ADB cluster. "
44-
value = concat(alicloud_adb_cluster.this.*.db_node_storage, [""])[0]
44+
value = alicloud_adb_db_cluster.this[*].db_node_storage
4545
}
4646

4747
output "this_adb_cluster_pay_type" {
4848
description = "The pay type."
49-
value = concat(alicloud_adb_cluster.this.*.pay_type, [""])[0]
50-
}
49+
value = alicloud_adb_db_cluster.this[*].pay_type
50+
}

variables.tf

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,26 @@
1-
# Provider
2-
variable "profile" {
3-
description = "(Deprecated from version 1.1.0) The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
4-
type = string
5-
default = ""
6-
}
7-
8-
variable "shared_credentials_file" {
9-
description = "(Deprecated from version 1.1.0) This is the path to the shared credentials file. If this is not set and a profile is specified, $HOME/.aliyun/config.json will be used."
10-
type = string
11-
default = ""
12-
}
13-
14-
variable "region" {
15-
description = "(Deprecated from version 1.1.0) The region used to launch this module resources."
16-
type = string
17-
default = ""
18-
}
19-
20-
variable "skip_region_validation" {
21-
description = "(Deprecated from version 1.1.0) Skip static validation of region ID. Used by users of alternative AlibabaCloud-like APIs or users w/ access to regions that are not public (yet)."
22-
type = bool
23-
default = false
24-
}
25-
261
# ADB Cluster
272
variable "create_cluster" {
283
description = "Whether to create ADB cluster. If false, you can use a existing ADB cluster by setting 'existing_cluster_id'."
294
type = bool
30-
default = false
5+
default = true
316
}
327

338
variable "existing_cluster_id" {
349
description = "The Id of an existing ADB cluster. It will be ignored when create_cluster = true."
3510
type = string
36-
default = ""
11+
default = null
3712
}
3813

3914
variable "vswitch_id" {
4015
description = "VSwitch variables, if vswitch_id is empty, then the net_type = classic."
4116
type = string
42-
default = ""
17+
default = null
4318
}
4419

4520
variable "availability_zone" {
4621
description = "The available zone to launch ADB cluster."
4722
type = string
48-
default = ""
23+
default = null
4924
}
5025

5126
variable "db_cluster_version" {
@@ -81,17 +56,17 @@ variable "db_node_storage" {
8156
variable "mode" {
8257
description = " The mode of the cluster. Valid values: reserver, flexible."
8358
type = string
84-
default = "reserver"
59+
default = null
8560
}
8661

87-
variable "pay_type" {
88-
description = "pay type, Valid value:Prepaid: The subscription billing method is used, Postpaid: The pay-as-you-go billing method is used."
62+
variable "payment_type" {
63+
description = "The payment type of the resource. Valid values: `PayAsYouGo` and `Subscription`. Default Value: `PayAsYouGo`"
8964
type = string
90-
default = "PostPaid"
65+
default = null
9166
}
9267

9368
variable "description" {
9469
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 '.', '-'."
9570
type = string
96-
default = ""
97-
}
71+
default = null
72+
}

0 commit comments

Comments
 (0)