Skip to content

Commit 3f3fed8

Browse files
authored
Feat/update example sean (#1965)
* feat/update-example-sean * feat/update-example-sean * feat/update-example-sean * feat/update-example-sean * feat/update-example-sean * feat/update-example-sean * feat/update-example-sean * feat/update-example-sean
1 parent b4ec81a commit 3f3fed8

File tree

185 files changed

+7919
-1292
lines changed

Some content is hidden

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

185 files changed

+7919
-1292
lines changed

examples/tencentcloud-as/main.tf

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
resource "tencentcloud_vpc" "vpc" {
2-
name = "tf-as-vpc"
3-
cidr_block = "10.2.0.0/16"
1+
data "tencentcloud_images" "example" {
2+
image_type = ["PUBLIC_IMAGE"]
3+
os_name = "TencentOS Server 3.2 (Final)"
44
}
55

6-
resource "tencentcloud_subnet" "subnet" {
7-
vpc_id = tencentcloud_vpc.vpc.id
8-
name = "tf-as-subnet"
9-
cidr_block = "10.2.11.0/24"
10-
availability_zone = var.availability_zone
11-
}
12-
13-
resource "tencentcloud_as_scaling_config" "launch_configuration" {
14-
configuration_name = "tf-as-configuration"
15-
image_id = "img-9qabwvbn"
16-
instance_types = [var.instance_type]
6+
resource "tencentcloud_as_scaling_config" "example" {
7+
configuration_name = "example-launch-configuration"
8+
image_id = data.tencentcloud_images.example.images.0.image_id
9+
instance_types = ["SA1.SMALL1"]
1710
project_id = 0
1811
system_disk_type = "CLOUD_PREMIUM"
1912
system_disk_size = "50"
@@ -26,76 +19,12 @@ resource "tencentcloud_as_scaling_config" "launch_configuration" {
2619
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
2720
internet_max_bandwidth_out = 10
2821
public_ip_assigned = true
29-
password = "test123#"
22+
password = "Test@123#"
3023
enhanced_security_service = false
3124
enhanced_monitor_service = false
32-
user_data = "test"
25+
user_data = "dGVzdA=="
3326

3427
instance_tags = {
35-
tag = "as"
28+
tag = "example"
3629
}
37-
}
38-
39-
resource "tencentcloud_as_scaling_group" "scaling_group" {
40-
scaling_group_name = "tf-as-scaling-group"
41-
configuration_id = tencentcloud_as_scaling_config.launch_configuration.id
42-
max_size = var.max_size
43-
min_size = var.min_size
44-
vpc_id = tencentcloud_vpc.vpc.id
45-
subnet_ids = [tencentcloud_subnet.subnet.id]
46-
project_id = 0
47-
default_cooldown = 400
48-
desired_capacity = var.desired_capacity
49-
termination_policies = ["NEWEST_INSTANCE"]
50-
retry_policy = "INCREMENTAL_INTERVALS"
51-
52-
tags = {
53-
"test" = "test"
54-
}
55-
}
56-
57-
resource "tencentcloud_as_scaling_policy" "scaling_policy" {
58-
scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
59-
policy_name = "tf-as-scaling-policy"
60-
adjustment_type = "EXACT_CAPACITY"
61-
adjustment_value = 2
62-
comparison_operator = "GREATER_THAN"
63-
metric_name = "CPU_UTILIZATION"
64-
threshold = 80
65-
period = 300
66-
continuous_time = 10
67-
statistic = "AVERAGE"
68-
cooldown = 360
69-
}
70-
71-
resource "tencentcloud_as_schedule" "schedule" {
72-
scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
73-
schedule_action_name = "tf-as-schedule"
74-
max_size = var.max_size
75-
min_size = var.min_size
76-
desired_capacity = var.desired_capacity
77-
start_time = "2020-01-01T00:00:00+08:00"
78-
end_time = "2020-12-01T00:00:00+08:00"
79-
recurrence = "0 0 */1 * *"
80-
}
81-
82-
resource "tencentcloud_as_lifecycle_hook" "lifecycle_hook" {
83-
scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
84-
lifecycle_hook_name = "tf-as-lifecycle"
85-
lifecycle_transition = "INSTANCE_TERMINATING"
86-
default_result = "ABANDON"
87-
heartbeat_timeout = 300
88-
notification_metadata = "tf lifecycle test"
89-
notification_target_type = "CMQ_QUEUE"
90-
notification_queue_name = "notification"
91-
}
92-
93-
resource "tencentcloud_as_notification" "notification" {
94-
scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
95-
notification_types = ["SCALE_OUT_FAILED"]
96-
notification_user_group_ids = ["76955"]
97-
}
98-
99-
data "tencentcloud_as_scaling_groups" "scaling_groups_tags" {
100-
tags = tencentcloud_as_scaling_group.scaling_group.tags
101-
}
30+
}
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +0,0 @@
1-
variable "availability_zone" {
2-
default = "ap-guangzhou-3"
3-
}
4-
5-
variable "instance_type" {
6-
default = "SA1.SMALL1"
7-
}
8-
9-
variable "min_size" {
10-
default = 0
11-
}
12-
13-
variable "max_size" {
14-
default = 5
15-
}
16-
17-
variable "desired_capacity" {
18-
default = 0
19-
}
20-
21-
variable "cvm_product" {
22-
default = "cvm"
23-
}
Lines changed: 35 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,46 @@
1-
resource "tencentcloud_mysql_instance" "main" {
2-
mem_size = 1000
3-
volume_size = 50
4-
instance_name = "testAccMysql"
5-
engine_version = "5.7"
6-
root_password = "test1234"
7-
availability_zone = var.availability_zone
8-
internet_service = 1
9-
slave_sync_mode = 1
10-
intranet_port = 3360
11-
12-
tags = {
13-
purpose = "for test"
14-
}
15-
16-
parameters = {
17-
max_connections = "1000"
18-
}
19-
}
20-
21-
resource "tencentcloud_mysql_readonly_instance" "readonly" {
22-
master_instance_id = tencentcloud_mysql_instance.main.id
23-
mem_size = 1000
24-
volume_size = 50
25-
instance_name = "testAccMysql_readonly"
26-
intranet_port = 3360
1+
data "tencentcloud_availability_zones" "zones" {}
272

28-
tags = {
29-
purpose = "for test"
30-
}
3+
resource "tencentcloud_vpc" "vpc" {
4+
name = "vpc-mysql"
5+
cidr_block = var.vpc_cidr
316
}
327

33-
data "tencentcloud_mysql_parameter_list" "mysql" {
34-
mysql_id = tencentcloud_mysql_instance.main.id
8+
resource "tencentcloud_subnet" "subnet" {
9+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
10+
name = "subnet-mysql"
11+
vpc_id = tencentcloud_vpc.vpc.id
12+
cidr_block = var.subnet_cidr
13+
is_multicast = false
3514
}
3615

37-
resource "tencentcloud_mysql_account" "mysql_account" {
38-
mysql_id = tencentcloud_mysql_instance.main.id
39-
name = "test"
40-
password = "test1234"
41-
description = "for test"
16+
resource "tencentcloud_security_group" "security_group" {
17+
name = "sg-mysql"
18+
description = "mysql test"
4219
}
4320

44-
resource "tencentcloud_mysql_privilege" "privilege" {
45-
mysql_id = tencentcloud_mysql_instance.main.id
46-
account_name = tencentcloud_mysql_account.mysql_account.name
47-
global = ["TRIGGER"]
48-
database {
49-
privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE"]
50-
database_name = "sys"
51-
}
52-
database {
53-
privileges = ["SELECT"]
54-
database_name = "performance_schema"
55-
}
56-
57-
table {
58-
privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "CREATE"]
59-
database_name = "mysql"
60-
table_name = "slow_log"
61-
}
21+
resource "tencentcloud_mysql_instance" "example" {
22+
internet_service = 1
23+
engine_version = "5.7"
24+
charge_type = "POSTPAID"
25+
root_password = "PassWord123"
26+
slave_deploy_mode = 1
27+
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
28+
first_slave_zone = data.tencentcloud_availability_zones.zones.zones.1.name
29+
slave_sync_mode = 1
30+
instance_name = "tf-example-mysql"
31+
mem_size = 4000
32+
volume_size = 200
33+
vpc_id = tencentcloud_vpc.vpc.id
34+
subnet_id = tencentcloud_subnet.subnet.id
35+
intranet_port = 3306
36+
security_groups = [tencentcloud_security_group.security_group.id]
6237

63-
table {
64-
privileges = ["SELECT", "INSERT", "UPDATE"]
65-
database_name = "mysql"
66-
table_name = "user"
38+
tags = {
39+
name = "test"
6740
}
6841

69-
column {
70-
privileges = ["SELECT", "INSERT", "UPDATE", "REFERENCES"]
71-
database_name = "mysql"
72-
table_name = "user"
73-
column_name = "host"
42+
parameters = {
43+
character_set_server = "utf8"
44+
max_connections = "1000"
7445
}
75-
}
76-
77-
resource "tencentcloud_mysql_backup_policy" "mysql_backup_policy" {
78-
mysql_id = tencentcloud_mysql_instance.main.id
79-
retention_period = 56
80-
backup_model = "physical"
81-
backup_time = "10:00-14:00"
82-
}
83-
84-
46+
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
variable "availability_zone" {
2-
default = "ap-guangzhou-3"
1+
variable "vpc_cidr" {
2+
default = "10.0.0.0/16"
3+
}
4+
5+
variable "subnet_cidr" {
6+
default = "10.0.0.0/16"
37
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "tencentcloud_vpc" "vpc" {
2+
cidr_block = "10.0.0.0/16"
3+
name = "tf_nat_gateway_vpc"
4+
}
5+
6+
resource "tencentcloud_eip" "eip_example1" {
7+
name = "tf_nat_gateway_eip1"
8+
}
9+
10+
resource "tencentcloud_eip" "eip_example2" {
11+
name = "tf_nat_gateway_eip2"
12+
}
13+
14+
resource "tencentcloud_nat_gateway" "example" {
15+
name = "tf_example_nat_gateway"
16+
vpc_id = tencentcloud_vpc.vpc.id
17+
bandwidth = 100
18+
max_concurrent = 1000000
19+
assigned_eip_set = [
20+
tencentcloud_eip.eip_example1.public_ip,
21+
tencentcloud_eip.eip_example2.public_ip,
22+
]
23+
tags = {
24+
tf_tag_key = "tf_tag_value"
25+
}
26+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
terraform {
2-
required_version = ">= 0.12"
3-
}
1+
terraform {
2+
required_version = ">= 0.12"
3+
}

0 commit comments

Comments
 (0)