Skip to content

Commit 81380ec

Browse files
committed
Module: remove deprecated attributes; improve the submodules;
1 parent 975c0bb commit 81380ec

File tree

41 files changed

+151
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+151
-693
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Local .terraform directories
22
**/.terraform/*
3+
**/.terraform.lock.hcl
34

45
# .tfstate files
56
*.tfstate
File renamed without changes.

example/complete/main.tf renamed to examples/complete/main.tf

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
variable "region" {
2-
default = "cn-beijing"
3-
}
41
provider "alicloud" {
52
region = var.region
63
}
@@ -29,16 +26,18 @@ resource "alicloud_vswitch" "default" {
2926
vswitch_name = "terraform-example"
3027
cidr_block = "10.4.0.0/24"
3128
vpc_id = alicloud_vpc.default.id
32-
zone_id = data.alicloud_db_zones.default.zones.0.id
29+
zone_id = data.alicloud_db_zones.default.zones[0].id
3330
}
3431
module "security_group" {
35-
source = "alibaba/security-group/alicloud"
32+
source = "alibaba/security-group/alicloud"
33+
version = "~>2.4.0"
34+
3635
region = var.region
3736
vpc_id = alicloud_vpc.default.id
3837
}
3938

4039
data "alicloud_db_instance_classes" "default" {
41-
zone_id = data.alicloud_db_zones.default.zones.0.id
40+
zone_id = data.alicloud_db_zones.default.zones[0].id
4241
engine = local.engine
4342
engine_version = local.engine_version
4443
category = local.category
@@ -47,17 +46,16 @@ data "alicloud_db_instance_classes" "default" {
4746
}
4847
module "postgres" {
4948
source = "../../"
50-
region = var.region
5149

5250
#################
5351
# Rds Instance
5452
#################
5553
create_instance = true
5654
engine_version = local.engine_version
57-
instance_type = data.alicloud_db_instance_classes.default.instance_classes.0.instance_class
55+
instance_type = data.alicloud_db_instance_classes.default.instance_classes[0].instance_class
5856
vswitch_id = alicloud_vswitch.default.id
5957
instance_name = "PostgreSQLInstance"
60-
instance_storage = data.alicloud_db_instance_classes.default.instance_classes.0.storage_range.min
58+
instance_storage = data.alicloud_db_instance_classes.default.instance_classes[0].storage_range.min
6159
instance_charge_type = "Postpaid"
6260
security_group_ids = [module.security_group.this_security_group_id]
6361
security_ips = ["11.193.54.0/24", "101.37.74.0/24", ]
@@ -104,4 +102,4 @@ module "postgres" {
104102
alarm_rule_threshold = 35
105103
alarm_rule_triggered_count = 2
106104
alarm_rule_contact_groups = ["postgre"]
107-
}
105+
}

example/complete/outputs.tf renamed to examples/complete/outputs.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ output "this_alarm_rule_enabled" {
7676
value = module.postgres.this_alarm_rule_enabled
7777
}
7878

79-
output "this_alarm_rule_webhook" {
80-
description = "The webhook that is called when the alarm is triggered."
81-
value = module.postgres.this_alarm_rule_webhook
82-
}
83-
8479
output "this_alarm_rule_cpu_usage_status" {
8580
description = "The current alarm cpu usage rule status."
8681
value = module.postgres.this_alarm_rule_cpu_usage_status
@@ -135,10 +130,6 @@ output "this_db_instance_name" {
135130
value = module.postgres.this_db_instance_name
136131
}
137132

138-
output "this_db_instance_period" {
139-
description = "Postgre SQL instance charge period when Prepaid."
140-
value = module.postgres.this_db_instance_period
141-
}
142133

143134
output "this_db_instance_security_ips" {
144135
description = "Postgre SQL instance security ip list."

examples/complete/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "region" {
2+
description = "The region of the resources."
3+
default = "cn-beijing"
4+
type = string
5+
}
File renamed without changes.
File renamed without changes.

example/using-existing-rds-instance/main.tf renamed to examples/using-existing-rds-instance/main.tf

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1-
variable "region" {
2-
default = "cn-beijing"
3-
}
41
provider "alicloud" {
52
region = var.region
63
}
4+
5+
# 创建VPC
6+
resource "alicloud_vpc" "main" {
7+
vpc_name = "alicloud"
8+
cidr_block = "172.16.0.0/16"
9+
}
10+
11+
# 创建交换机
12+
resource "alicloud_vswitch" "main" {
13+
vpc_id = alicloud_vpc.main.id
14+
cidr_block = "172.16.192.0/20"
15+
zone_id = "cn-hangzhou-b"
16+
}
17+
18+
# 创建RDS PostgreSQL实例
19+
resource "alicloud_db_instance" "instance" {
20+
engine = "PostgreSQL"
21+
engine_version = "13.0"
22+
instance_type = "pg.n2.2c.2m"
23+
instance_storage = "30"
24+
instance_charge_type = "Postpaid"
25+
vswitch_id = alicloud_vswitch.main.id
26+
}
27+
728
module "postgres" {
829
source = "../../"
9-
region = var.region
1030

1131
#################
1232
# Rds Instance
1333
#################
14-
existing_instance_id = "pgm-2zehbutrxxxxxx"
34+
create_instance = false
35+
existing_instance_id = alicloud_db_instance.instance.id
1536

1637
#################
1738
# Rds Backup policy
@@ -40,7 +61,7 @@ module "postgres" {
4061
#######################
4162
account_privilege = "DBOwner"
4263
account_name = "account_name"
43-
account_password = "yourpassword123"
64+
account_password = "Example12345"
4465

4566
#############
4667
# Alarm Rule
@@ -52,4 +73,4 @@ module "postgres" {
5273
alarm_rule_threshold = 35
5374
alarm_rule_triggered_count = 2
5475
alarm_rule_contact_groups = ["postgre"]
55-
}
76+
}

example/using-existing-rds-instance/outputs.tf renamed to examples/using-existing-rds-instance/outputs.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ output "this_alarm_rule_enabled" {
7676
value = module.postgres.this_alarm_rule_enabled
7777
}
7878

79-
output "this_alarm_rule_webhook" {
80-
description = "The webhook that is called when the alarm is triggered."
81-
value = module.postgres.this_alarm_rule_webhook
82-
}
83-
8479
output "this_alarm_rule_cpu_usage_status" {
8580
description = "The current alarm cpu usage rule status."
8681
value = module.postgres.this_alarm_rule_cpu_usage_status
@@ -135,11 +130,6 @@ output "this_db_instance_name" {
135130
value = module.postgres.this_db_instance_name
136131
}
137132

138-
output "this_db_instance_period" {
139-
description = "Postgre SQL instance charge period when Prepaid."
140-
value = module.postgres.this_db_instance_period
141-
}
142-
143133
output "this_db_instance_security_ips" {
144134
description = "Postgre SQL instance security ip list."
145135
value = module.postgres.this_db_instance_security_ips
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "region" {
2+
description = "The region of the resources."
3+
default = "cn-hangzhou"
4+
type = string
5+
}

0 commit comments

Comments
 (0)