Skip to content

Commit

Permalink
module: support attibute category,serverless_config and deprecate off…
Browse files Browse the repository at this point in the history
…line submodules; examples: improve the examples
  • Loading branch information
shanye997 committed Nov 4, 2024
1 parent 2ba697d commit be8bc51
Show file tree
Hide file tree
Showing 79 changed files with 294 additions and 2,824 deletions.
14 changes: 9 additions & 5 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ data "alicloud_db_instance_classes" "default" {
}

module "vpc" {
source = "alibaba/vpc/alicloud"
source = "alibaba/vpc/alicloud"
version = "~>1.11.0"

create = true
vpc_cidr = "172.16.0.0/16"
vswitch_cidrs = ["172.16.0.0/21"]
availability_zones = [data.alicloud_db_zones.default.zones.0.id]
availability_zones = [data.alicloud_db_zones.default.zones[0].id]
}

module "security_group" {
source = "alibaba/security-group/alicloud"
source = "alibaba/security-group/alicloud"
version = "~>2.4.0"

vpc_id = module.vpc.this_vpc_id
}

Expand All @@ -29,7 +33,7 @@ module "rds" {
engine_version = "5.6"

instance_name = var.instance_name
instance_type = data.alicloud_db_instance_classes.default.instance_classes.0.instance_class
instance_type = data.alicloud_db_instance_classes.default.instance_classes[1].instance_class
instance_storage_type = "local_ssd"
instance_storage = var.instance_storage
instance_charge_type = var.instance_charge_type
Expand Down Expand Up @@ -70,4 +74,4 @@ module "rds" {
type = "Normal"
privilege = "ReadOnly"

}
}
5 changes: 0 additions & 5 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ output "this_db_instance_name" {
value = module.rds.this_db_instance_name
}

output "this_db_instance_period" {
description = "Rds instance charge period when Prepaid."
value = module.rds.this_db_instance_period
}

output "this_db_instance_security_ips" {
description = "Rds instance security ip list."
value = module.rds.this_db_instance_security_ips
Expand Down
1 change: 0 additions & 1 deletion examples/complete/tfvars/01-update.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Rds Instance
#################
instance_name = "update-tf-testacc-name"
instance_storage = 25
period = 2
security_ips = ["10.23.12.24"]
sql_collector_status = "Disabled"
Expand Down
File renamed without changes.
26 changes: 9 additions & 17 deletions examples/mysql/main.tf
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
variable "region" {
default = "cn-hangzhou"
}
variable "profile" {
default = "default"
}
provider "alicloud" {
region = var.region
profile = var.profile
region = var.region
}
data "alicloud_vpcs" "default" {
is_default = true
}
module "security_group" {
source = "alibaba/security-group/alicloud"
region = var.region
profile = var.profile
vpc_id = data.alicloud_vpcs.default.ids.0
source = "alibaba/security-group/alicloud"

vpc_id = data.alicloud_vpcs.default.ids[0]
version = "~> 2.0"
}
module "mysql" {
source = "../../modules/mysql-8.0-high-availability"
region = var.region
profile = var.profile
source = "../../modules/mysql-8.0-high-availability"

#################
# Rds Instance
#################
connection_prefix = "developmentabc"
vswitch_id = data.alicloud_vpcs.default.vpcs.0.vswitch_ids.0
vswitch_id = data.alicloud_vpcs.default.vpcs[0].vswitch_ids[0]
instance_name = "myDBInstance"
instance_type = "rds.mysql.t1.small"
security_group_ids = [module.security_group.this_security_group_id]
Expand Down Expand Up @@ -63,11 +54,12 @@ module "mysql" {
# Rds Database account
#################
account_name = "account_name1"
password = "1234abc"
password = "Example1234"
tags = {
Env = "Private"
Location = "Secret"
}

}


Expand Down
104 changes: 0 additions & 104 deletions examples/mysql/output.tf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ output "this_db_instance_name" {
description = "Rds instance name."
value = module.mysql.this_db_instance_name
}
output "this_db_instance_period" {
description = "Rds instance charge period when Prepaid."
value = module.mysql.this_db_instance_period
}
output "this_db_instance_security_ips" {
description = "Rds instance security ip list."
value = module.mysql.this_db_instance_security_ips
Expand Down
5 changes: 5 additions & 0 deletions examples/mysql/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "region" {
default = "cn-hangzhou"
description = "The region of the RDS instance."
type = string
}
58 changes: 41 additions & 17 deletions examples/postgre_sql/main.tf
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
variable "region" {
default = "cn-beijing"
}
variable "profile" {
default = "default"
}
provider "alicloud" {
region = var.region
profile = var.profile
region = var.region
}
data "alicloud_vpcs" "default" {
is_default = true
}

module "security_group" {
source = "alibaba/security-group/alicloud"
region = var.region
profile = var.profile
vpc_id = data.alicloud_vpcs.default.ids.0
version = "~> 2.0"

vpc_id = data.alicloud_vpcs.default.ids[0]

}

data "alicloud_db_zones" "example" {
engine = "PostgreSQL"
engine_version = "14.0"
instance_charge_type = "Serverless"
category = "serverless_basic"
db_instance_storage_type = "cloud_essd"
}

data "alicloud_db_instance_classes" "example" {
zone_id = data.alicloud_db_zones.example.ids[1]
engine = "PostgreSQL"
engine_version = "14.0"
category = "serverless_basic"
db_instance_storage_type = "cloud_essd"
instance_charge_type = "Serverless"
commodity_code = "rds_serverless_public_cn"
}

module "postgre_sql" {
source = "../../modules/postgre_sql-9.4-high-availability"
source = "../.."
connection_prefix = "developmentabc"
region = var.region
profile = var.profile

#################
# Rds Instance
#################
vswitch_id = data.alicloud_vpcs.default.vpcs.0.vswitch_ids.0
instance_type = "rds.pg.s1.small"
instance_name = "myDBInstance"
vswitch_id = data.alicloud_vpcs.default.vpcs[0].vswitch_ids[0]
engine = "PostgreSQL"
engine_version = "14.0"
instance_storage = data.alicloud_db_instance_classes.example.instance_classes[0].storage_range.min
instance_type = data.alicloud_db_instance_classes.example.instance_classes[0].instance_class
instance_charge_type = "Serverless"
instance_storage_type = "cloud_essd"
instance_name = "myDBInstance"
category = "serverless_basic"
serverless_config = [{
max_capacity = 8
min_capacity = 2
}]
security_group_ids = [module.security_group.this_security_group_id]
security_ips = [
"11.193.54.0/24",
Expand All @@ -47,5 +68,8 @@ module "postgre_sql" {
Env = "Private"
Location = "Secret"
}
allocate_public_connection = false
create_database = false
create_account = false
}

4 changes: 0 additions & 4 deletions examples/postgre_sql/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ output "this_db_instance_name" {
description = "Rds instance name."
value = module.postgre_sql.this_db_instance_name
}
output "this_db_instance_period" {
description = "Rds instance charge period when Prepaid."
value = module.postgre_sql.this_db_instance_period
}
output "this_db_instance_security_ips" {
description = "Rds instance security ip list."
value = module.postgre_sql.this_db_instance_security_ips
Expand Down
5 changes: 5 additions & 0 deletions examples/postgre_sql/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "region" {
default = "cn-hangzhou"
description = "The region of the RDS instance."
type = string
}
15 changes: 0 additions & 15 deletions examples/ppas/README.md

This file was deleted.

45 changes: 0 additions & 45 deletions examples/ppas/main.tf

This file was deleted.

Loading

0 comments on commit be8bc51

Please sign in to comment.